|
1 | 1 | <?php |
| 2 | +declare(strict_types=1); |
| 3 | + |
2 | 4 | /** |
3 | 5 | * CakePHP(tm) : Rapid Development Framework (https://cakephp.org) |
4 | 6 | * Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org) |
|
30 | 32 | require CORE_PATH . 'config' . DS . 'bootstrap.php'; |
31 | 33 |
|
32 | 34 | use Cake\Cache\Cache; |
33 | | -use Cake\Console\ConsoleErrorHandler; |
34 | | -use Cake\Core\App; |
35 | 35 | use Cake\Core\Configure; |
36 | 36 | use Cake\Core\Configure\Engine\PhpConfig; |
37 | | -use Cake\Core\Plugin; |
38 | | -use Cake\Database\Type; |
39 | 37 | use Cake\Datasource\ConnectionManager; |
| 38 | +use Cake\Error\ConsoleErrorHandler; |
40 | 39 | use Cake\Error\ErrorHandler; |
41 | 40 | use Cake\Http\ServerRequest; |
42 | 41 | use Cake\Log\Log; |
43 | | -use Cake\Mailer\Email; |
44 | | -use Cake\Utility\Inflector; |
| 42 | +use Cake\Mailer\Mailer; |
| 43 | +use Cake\Mailer\TransportFactory; |
| 44 | +use Cake\Routing\Router; |
45 | 45 | use Cake\Utility\Security; |
46 | 46 |
|
47 | | -/** |
48 | | - * Read .env file if APP_NAME is not set. |
| 47 | +/* |
| 48 | + * See https://github.com/josegonzalez/php-dotenv for API details. |
49 | 49 | * |
50 | | - * You can remove this block if you do not want to use environment |
51 | | - * variables for configuration when deploying. |
52 | | - */ |
53 | | -if (!env('APP_NAME') && file_exists(CONFIG . '.env')) { |
54 | | - $dotenv = new \josegonzalez\Dotenv\Loader([CONFIG . '.env']); |
55 | | - $dotenv->parse() |
56 | | - ->putenv() |
57 | | - ->toEnv() |
58 | | - ->toServer(); |
59 | | -} |
| 50 | + * Uncomment block of code below if you want to use `.env` file during development. |
| 51 | + * You should copy `config/.env.example` to `config/.env` and set/modify the |
| 52 | + * variables as required. |
| 53 | + * |
| 54 | + * The purpose of the .env file is to emulate the presence of the environment |
| 55 | + * variables like they would be present in production. |
| 56 | + * |
| 57 | + * If you use .env files, be careful to not commit them to source control to avoid |
| 58 | + * security risks. See https://github.com/josegonzalez/php-dotenv#general-security-information |
| 59 | + * for more information for recommended practices. |
| 60 | +*/ |
| 61 | +// if (!env('APP_NAME') && file_exists(CONFIG . '.env')) { |
| 62 | +// $dotenv = new \josegonzalez\Dotenv\Loader([CONFIG . '.env']); |
| 63 | +// $dotenv->parse() |
| 64 | +// ->putenv() |
| 65 | +// ->toEnv() |
| 66 | +// ->toServer(); |
| 67 | +// } |
60 | 68 |
|
61 | 69 | /* |
62 | 70 | * Read configuration file and inject configuration into various |
|
74 | 82 | } |
75 | 83 |
|
76 | 84 | /* |
77 | | - * Load an environment local configuration file. |
78 | | - * You can use a file like app_local.php to provide local overrides to your |
79 | | - * shared configuration. |
| 85 | + * Load an environment local configuration file to provide overrides to your configuration. |
| 86 | + * Notice: For security reasons app_local.php **should not** be included in your git repo. |
80 | 87 | */ |
81 | | -//Configure::load('app_local', 'default'); |
| 88 | +if (file_exists(CONFIG . 'app_local.php')) { |
| 89 | + Configure::load('app_local', 'default'); |
| 90 | +} |
82 | 91 |
|
83 | 92 | /* |
84 | 93 | * When debug = true the metadata cache should only last |
|
87 | 96 | if (Configure::read('debug')) { |
88 | 97 | Configure::write('Cache._cake_model_.duration', '+2 minutes'); |
89 | 98 | Configure::write('Cache._cake_core_.duration', '+2 minutes'); |
| 99 | + // disable router cache during development |
| 100 | + Configure::write('Cache._cake_routes_.duration', '+2 seconds'); |
90 | 101 | } |
91 | 102 |
|
92 | 103 | /* |
93 | | - * Set server timezone to UTC. You can change it to another timezone of your |
94 | | - * choice but using UTC makes time calculations / conversions easier. |
| 104 | + * Set the default server timezone. Using UTC makes time calculations / conversions easier. |
95 | 105 | * Check http://php.net/manual/en/timezones.php for list of valid timezone strings. |
96 | 106 | */ |
97 | | -date_default_timezone_set('UTC'); |
| 107 | +date_default_timezone_set(Configure::read('App.defaultTimezone')); |
98 | 108 |
|
99 | 109 | /* |
100 | 110 | * Configure the mbstring extension to use the correct encoding. |
|
127 | 137 | /* |
128 | 138 | * Set the full base URL. |
129 | 139 | * This URL is used as the base of all absolute links. |
130 | | - * |
131 | | - * If you define fullBaseUrl in your config file you can remove this. |
132 | 140 | */ |
133 | | -if (!Configure::read('App.fullBaseUrl')) { |
| 141 | +$fullBaseUrl = Configure::read('App.fullBaseUrl'); |
| 142 | +if (!$fullBaseUrl) { |
134 | 143 | $s = null; |
135 | 144 | if (env('HTTPS')) { |
136 | 145 | $s = 's'; |
137 | 146 | } |
138 | 147 |
|
139 | 148 | $httpHost = env('HTTP_HOST'); |
140 | 149 | if (isset($httpHost)) { |
141 | | - Configure::write('App.fullBaseUrl', 'http' . $s . '://' . $httpHost); |
| 150 | + $fullBaseUrl = 'http' . $s . '://' . $httpHost; |
142 | 151 | } |
143 | 152 | unset($httpHost, $s); |
144 | 153 | } |
| 154 | +if ($fullBaseUrl) { |
| 155 | + Router::fullBaseUrl($fullBaseUrl); |
| 156 | +} |
| 157 | +unset($fullBaseUrl); |
145 | 158 |
|
146 | 159 | Cache::setConfig(Configure::consume('Cache')); |
147 | 160 | ConnectionManager::setConfig(Configure::consume('Datasources')); |
148 | | -Email::setConfigTransport(Configure::consume('EmailTransport')); |
149 | | -Email::setConfig(Configure::consume('Email')); |
| 161 | +TransportFactory::setConfig(Configure::consume('EmailTransport')); |
| 162 | +Mailer::setConfig(Configure::consume('Email')); |
150 | 163 | Log::setConfig(Configure::consume('Log')); |
151 | 164 | Security::setSalt(Configure::consume('Security.salt')); |
152 | 165 |
|
153 | | -/* |
154 | | - * The default crypto extension in 3.0 is OpenSSL. |
155 | | - * If you are migrating from 2.x uncomment this code to |
156 | | - * use a more compatible Mcrypt based implementation |
157 | | - */ |
158 | | -//Security::engine(new \Cake\Utility\Crypto\Mcrypt()); |
159 | | - |
160 | 166 | /* |
161 | 167 | * Setup detectors for mobile and tablet. |
162 | 168 | */ |
|
172 | 178 | }); |
173 | 179 |
|
174 | 180 | /* |
175 | | - * Enable immutable time objects in the ORM. |
| 181 | + * You can set whether the ORM uses immutable or mutable Time types. |
| 182 | + * The default changed in 4.0 to immutable types. You can uncomment |
| 183 | + * below to switch back to mutable types. |
176 | 184 | * |
177 | 185 | * You can enable default locale format parsing by adding calls |
178 | 186 | * to `useLocaleParser()`. This enables the automatic conversion of |
179 | 187 | * locale specific date formats. For details see |
180 | | - * @link https://book.cakephp.org/3.0/en/core-libraries/internationalization-and-localization.html#parsing-localized-datetime-data |
181 | | - */ |
182 | | -Type::build('time') |
183 | | - ->useImmutable(); |
184 | | -Type::build('date') |
185 | | - ->useImmutable(); |
186 | | -Type::build('datetime') |
187 | | - ->useImmutable(); |
188 | | -Type::build('timestamp') |
189 | | - ->useImmutable(); |
| 188 | + * @link https://book.cakephp.org/4/en/core-libraries/internationalization-and-localization.html#parsing-localized-datetime-data |
| 189 | + */ |
| 190 | +// TypeFactory::build('time') |
| 191 | +// ->useMutable(); |
| 192 | +// TypeFactory::build('date') |
| 193 | +// ->useMutable(); |
| 194 | +// TypeFactory::build('datetime') |
| 195 | +// ->useMutable(); |
| 196 | +// TypeFactory::build('timestamp') |
| 197 | +// ->useMutable(); |
| 198 | +// TypeFactory::build('datetimefractional') |
| 199 | +// ->useMutable(); |
| 200 | +// TypeFactory::build('timestampfractional') |
| 201 | +// ->useMutable(); |
| 202 | +// TypeFactory::build('datetimetimezone') |
| 203 | +// ->useMutable(); |
| 204 | +// TypeFactory::build('timestamptimezone') |
| 205 | +// ->useMutable(); |
190 | 206 |
|
191 | 207 | /* |
192 | 208 | * Custom Inflector rules, can be set to correctly pluralize or singularize |
|
197 | 213 | //Inflector::rules('irregular', ['red' => 'redlings']); |
198 | 214 | //Inflector::rules('uninflected', ['dontinflectme']); |
199 | 215 | //Inflector::rules('transliteration', ['/å/' => 'aa']); |
200 | | - |
201 | | -/* |
202 | | - * Plugins need to be loaded manually, you can either load them one by one or all of them in a single call |
203 | | - * Uncomment one of the lines below, as you need. make sure you read the documentation on Plugin to use more |
204 | | - * advanced ways of loading plugins |
205 | | - * |
206 | | - * Plugin::loadAll(); // Loads all plugins at once |
207 | | - * Plugin::load('Migrations'); //Loads a single plugin named Migrations |
208 | | - * |
209 | | - */ |
210 | | - |
211 | | -/* |
212 | | - * Only try to load DebugKit in development mode |
213 | | - * Debug Kit should not be installed on a production system |
214 | | - */ |
215 | | -if (Configure::read('debug')) { |
216 | | - Plugin::load('DebugKit', ['bootstrap' => true]); |
217 | | -} |
0 commit comments