OSDN Git Service

Повышена версия программы. Добавлено описание расширенного функционала.
[invent/invent.git] / config / web.php
1 <?php
2
3 use yii\helpers\Html;
4 use kartik\mpdf\Pdf;
5
6 $params = require __DIR__ . '/params.php';
7 $db = require __DIR__ . '/db.php';
8
9 function showUrlUpdate($name, $data) {
10         return Html::a(Html::encode($name), ['update', 'id' => $data->id]);
11 }
12
13
14 $config = [
15     'version' => '1.26',
16     'name' => 'Inventory',
17     'id' => 'basic',
18     'basePath' => dirname(__DIR__),
19     'language' => 'ru-RU',
20     'bootstrap' => ['log'],
21     'aliases' => [
22         '@bower' => '@vendor/bower-asset',
23         '@npm'   => '@vendor/npm-asset',
24     ],
25     'components' => [
26         'request' => [
27             // !!! insert a secret key in the following (if it is empty) - this is required by cookie validation
28             'cookieValidationKey' => '4u6WczdipA-FIzbuf8PYgjoiid_6zdNy',
29         ],
30         'pdf' => [
31             'mode' => Pdf::MODE_UTF8,
32             'class' => Pdf::className(),
33             'format' => Pdf::FORMAT_A4,
34             'orientation' => Pdf::ORIENT_PORTRAIT,
35             'destination' => Pdf::DEST_BROWSER,
36             'cssFile' => '@vendor/kartik-v/yii2-mpdf/src/assets/kv-mpdf-bootstrap.min.css',
37             'cssInline' => '.kv-heading-1{font-size:18px}',
38             'methods' => [
39                 'SetHeader' => [Yii::t('app', 'Inventory')],
40                 'SetFooter' => ['{PAGENO}'],
41             ],
42 //            'defaultFont' => 'DejaVu Sans',
43             // refer settings section for all configuration options
44         ],
45         /*
46         'response' => [
47             'formatters' => [
48                 'pdf' => [
49                     'class' => 'robregonm\pdf\PdfResponseFormatter',
50                     'format' => 'A4',
51                     'options' => [
52                         'title' => 'Document',
53                     ],
54                 ],
55             ],
56         ], // */
57         'cache' => [
58             'class' => 'yii\caching\FileCache',
59         ],
60         'user' => [
61             'identityClass' => 'app\models\User',
62             'enableAutoLogin' => true,
63         ],
64         'errorHandler' => [
65             'errorAction' => 'site/error',
66         ],
67         'mailer' => [
68             'class' => 'yii\swiftmailer\Mailer',
69             // send all mails to a file by default. You have to set
70             // 'useFileTransport' to false and configure a transport
71             // for the mailer to send real emails.
72             'useFileTransport' => false,
73         ],
74         'log' => [
75             'traceLevel' => YII_DEBUG ? 3 : 0,
76             'targets' => [
77                 [
78                     'class' => 'yii\log\FileTarget',
79                     'levels' => ['error', 'warning'],
80                 ],
81             ],
82         ],
83         'i18n' => [
84             'translations' => [
85                 'app*' => [
86                     'class' => 'yii\i18n\PhpMessageSource',
87                     'sourceLanguage' => 'en-US',
88                     'basePath' => '@app/messages',
89                     'fileMap' => [
90                         'app'       => 'app.php',
91                         'app/error' => 'error.php',
92                     ],
93                 ],
94                 'contact*' => [
95                     'class' => 'yii\i18n\PhpMessageSource',
96                     'sourceLanguage' => 'en-US',
97                     'basePath' => '@app/messages',
98                     'fileMap' => [
99                         'app'   => 'contact.app',
100                     ],
101                 ],
102                 'items*' => [
103                     'class' => 'yii\i18n\PhpMessageSource',
104                     'sourceLanguage' => 'en-US',
105                     'basePath' => '@app/messages',
106                     'fileMap' => [
107                         'app' => 'items.app',
108                     ],
109                 ],
110                 'locations*' => [
111                     'class' => 'yii\i18n\PhpMessageSource',
112                     'sourceLanguage' => 'en-US',
113                     'basePath' => '@app/messages',
114                     'fileMap' => [
115                         'app' => 'locations.app',
116                     ],
117                 ],
118                 'moving*' => [
119                     'class' => 'yii\i18n\PhpMessageSource',
120                     'sourceLanguage' => 'en-US',
121                     'basePath' => '@app/messages',
122                     'fileMap' => [
123                         'app'   => 'moving.app',
124                     ],
125                 ],
126                 'regions*' => [
127                     'class' => 'yii\i18n\PhpMessageSource',
128                     'sourceLanguage' => 'en-US',
129                     'basePath' => '@app/messages',
130                     'fileMap' => [
131                         'app' => 'regions.app',
132                     ],
133                 ],
134                 'status*' => [
135                     'class' => 'yii\i18n\PhpMessageSource',
136                     'sourceLanguage' => 'en-US',
137                     'basePath' => '@app/messages',
138                     'fileMap' => [
139                         'app' => 'status.app',
140                     ],
141                 ],
142                 'types*' => [
143                     'class' => 'yii\i18n\PhpMessageSource',
144                     'sourceLanguage' => 'en-US',
145                     'basePath' => '@app/messages',
146                     'fileMap' => [
147                         'app' => 'types.app',
148                     ],
149                 ],
150             ],
151         ],
152         'db' => $db,
153         /*
154         'urlManager' => [
155             'enablePrettyUrl' => true,
156             'showScriptName' => false,
157             'rules' => [
158             ],
159         ],
160         */
161     ],
162     'params' => $params,
163 ];
164
165 if (YII_ENV_DEV) {
166     // configuration adjustments for 'dev' environment
167     $config['bootstrap'][] = 'debug';
168     $config['modules']['debug'] = [
169         'class' => 'yii\debug\Module',
170         // uncomment the following to add your IP if you are not connecting from localhost.
171         'allowedIPs' => ['127.0.0.1', '::1', '192.168.0.68'],
172     ];
173
174     $config['bootstrap'][] = 'gii';
175     $config['modules']['gii'] = [
176         'class' => 'yii\gii\Module',
177         // uncomment the following to add your IP if you are not connecting from localhost.
178         'allowedIPs' => ['127.0.0.1', '::1', '192.168.0.68'],
179     ];
180 }
181
182 return $config;