|
15 | 15 | * @license https://opensource.org/licenses/mit-license.php MIT License |
16 | 16 | */ |
17 | 17 |
|
| 18 | +/* |
| 19 | + * This file is loaded by your src/Application.php bootstrap method. |
| 20 | + * Feel free to extend/extract parts of the bootstrap process into your own files |
| 21 | + * to suit your needs/preferences. |
| 22 | + */ |
| 23 | + |
18 | 24 | /* |
19 | 25 | * Configure paths required to find CakePHP + general filepath constants |
20 | 26 | */ |
21 | 27 | require __DIR__ . DIRECTORY_SEPARATOR . 'paths.php'; |
22 | 28 |
|
23 | 29 | /* |
24 | | - * Bootstrap CakePHP. |
25 | | - * |
26 | | - * Does the various bits of setup that CakePHP needs to do. |
27 | | - * This includes: |
28 | | - * |
29 | | - * - Registering the CakePHP autoloader. |
30 | | - * - Setting the default application paths. |
| 30 | + * Bootstrap CakePHP |
| 31 | + * Currently all this does is initialize the router (without loading your routes) |
31 | 32 | */ |
32 | 33 | require CORE_PATH . 'config' . DS . 'bootstrap.php'; |
33 | 34 |
|
|
44 | 45 | use Cake\Routing\Router; |
45 | 46 | use Cake\Utility\Security; |
46 | 47 |
|
47 | | -/** |
48 | | - * Load global functions. |
| 48 | +/* |
| 49 | + * Load global functions for collections, translations, debugging etc. |
49 | 50 | */ |
50 | 51 | require CAKE . 'functions.php'; |
51 | 52 |
|
|
72 | 73 | // } |
73 | 74 |
|
74 | 75 | /* |
75 | | - * Read configuration file and inject configuration into various |
76 | | - * CakePHP classes. |
| 76 | + * Initializes default Config store and loads the main configuration file (app.php) |
77 | 77 | * |
78 | | - * By default there is only one configuration file. It is often a good |
79 | | - * idea to create multiple configuration files, and separate the configuration |
80 | | - * that changes from configuration that does not. This makes deployment simpler. |
| 78 | + * CakePHP contains 2 configuration files after project creation: |
| 79 | + * - `config/app.php` for the default application configuration. |
| 80 | + * - `config/app_local.php` for environment specific configuration. |
81 | 81 | */ |
82 | 82 | try { |
83 | 83 | Configure::config('default', new PhpConfig()); |
|
95 | 95 | } |
96 | 96 |
|
97 | 97 | /* |
98 | | - * When debug = true the metadata cache should only last |
99 | | - * for a short time. |
| 98 | + * When debug = true the metadata cache should only last for a short time. |
100 | 99 | */ |
101 | 100 | if (Configure::read('debug')) { |
102 | 101 | Configure::write('Cache._cake_model_.duration', '+2 minutes'); |
|
127 | 126 | (new ExceptionTrap(Configure::read('Error')))->register(); |
128 | 127 |
|
129 | 128 | /* |
130 | | - * Include the CLI bootstrap overrides. |
| 129 | + * CLI/Command specific configuration. |
131 | 130 | */ |
132 | 131 | if (PHP_SAPI === 'cli') { |
133 | | - require CONFIG . 'bootstrap_cli.php'; |
| 132 | + // Set the fullBaseUrl to allow URLs to be generated in commands. |
| 133 | + // This is useful when sending email from commands. |
| 134 | + // Configure::write('App.fullBaseUrl', php_uname('n')); |
| 135 | + |
| 136 | + // Set logs to different files so they don't have permission conflicts. |
| 137 | + if (Configure::check('Log.debug')) { |
| 138 | + Configure::write('Log.debug.file', 'cli-debug'); |
| 139 | + } |
| 140 | + if (Configure::check('Log.error')) { |
| 141 | + Configure::write('Log.error.file', 'cli-error'); |
| 142 | + } |
134 | 143 | } |
135 | 144 |
|
136 | 145 | /* |
137 | 146 | * Set the full base URL. |
138 | 147 | * This URL is used as the base of all absolute links. |
| 148 | + * Can be very useful for CLI/Commandline applications. |
139 | 149 | */ |
140 | 150 | $fullBaseUrl = Configure::read('App.fullBaseUrl'); |
141 | 151 | if (!$fullBaseUrl) { |
|
165 | 175 | } |
166 | 176 | unset($fullBaseUrl); |
167 | 177 |
|
| 178 | +/* |
| 179 | + * Apply the loaded configuration settings to their respective systems. |
| 180 | + * This will also remove the loaded config data from memory. |
| 181 | + */ |
168 | 182 | Cache::setConfig(Configure::consume('Cache')); |
169 | 183 | ConnectionManager::setConfig(Configure::consume('Datasources')); |
170 | 184 | TransportFactory::setConfig(Configure::consume('EmailTransport')); |
|
191 | 205 | /* |
192 | 206 | * You can enable default locale format parsing by adding calls |
193 | 207 | * to `useLocaleParser()`. This enables the automatic conversion of |
194 | | - * locale specific date formats. For details see |
| 208 | + * locale specific date formats when processing request data. For details see |
195 | 209 | * @link https://book.cakephp.org/5/en/core-libraries/internationalization-and-localization.html#parsing-localized-datetime-data |
196 | 210 | */ |
197 | | -// \Cake\Database\TypeFactory::build('time') |
198 | | -// ->useLocaleParser(); |
199 | | -// \Cake\Database\TypeFactory::build('date') |
200 | | -// ->useLocaleParser(); |
201 | | -// \Cake\Database\TypeFactory::build('datetime') |
202 | | -// ->useLocaleParser(); |
203 | | -// \Cake\Database\TypeFactory::build('timestamp') |
204 | | -// ->useLocaleParser(); |
205 | | -// \Cake\Database\TypeFactory::build('datetimefractional') |
206 | | -// ->useLocaleParser(); |
207 | | -// \Cake\Database\TypeFactory::build('timestampfractional') |
208 | | -// ->useLocaleParser(); |
209 | | -// \Cake\Database\TypeFactory::build('datetimetimezone') |
210 | | -// ->useLocaleParser(); |
211 | | -// \Cake\Database\TypeFactory::build('timestamptimezone') |
212 | | -// ->useLocaleParser(); |
| 211 | +// \Cake\Database\TypeFactory::build('time')->useLocaleParser(); |
| 212 | +// \Cake\Database\TypeFactory::build('date')->useLocaleParser(); |
| 213 | +// \Cake\Database\TypeFactory::build('datetime')->useLocaleParser(); |
| 214 | +// \Cake\Database\TypeFactory::build('timestamp')->useLocaleParser(); |
| 215 | +// \Cake\Database\TypeFactory::build('datetimefractional')->useLocaleParser(); |
| 216 | +// \Cake\Database\TypeFactory::build('timestampfractional')->useLocaleParser(); |
| 217 | +// \Cake\Database\TypeFactory::build('datetimetimezone')->useLocaleParser(); |
| 218 | +// \Cake\Database\TypeFactory::build('timestamptimezone')->useLocaleParser(); |
213 | 219 |
|
214 | 220 | /* |
215 | 221 | * Custom Inflector rules, can be set to correctly pluralize or singularize |
216 | 222 | * table, model, controller names or whatever other string is passed to the |
217 | 223 | * inflection functions. |
218 | 224 | */ |
219 | | -//Inflector::rules('plural', ['/^(inflect)or$/i' => '\1ables']); |
220 | | -//Inflector::rules('irregular', ['red' => 'redlings']); |
221 | | -//Inflector::rules('uninflected', ['dontinflectme']); |
| 225 | +// \Cake\Utility\Inflector::rules('plural', ['/^(inflect)or$/i' => '\1ables']); |
| 226 | +// \Cake\Utility\Inflector::rules('irregular', ['red' => 'redlings']); |
| 227 | +// \Cake\Utility\Inflector::rules('uninflected', ['dontinflectme']); |
222 | 228 |
|
223 | 229 | // set a custom date and time format |
224 | 230 | // see https://book.cakephp.org/5/en/core-libraries/time.html#setting-the-default-locale-and-format-string |
225 | 231 | // and https://unicode-org.github.io/icu/userguide/format_parse/datetime/#datetime-format-syntax |
226 | | -//\Cake\I18n\Date::setToStringFormat('dd.MM.yyyy'); |
227 | | -//\Cake\I18n\Time::setToStringFormat('dd.MM.yyyy HH:mm'); |
| 232 | +// \Cake\I18n\Date::setToStringFormat('dd.MM.yyyy'); |
| 233 | +// \Cake\I18n\Time::setToStringFormat('dd.MM.yyyy HH:mm'); |
0 commit comments