Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

improve bootstrap docs #1029

Merged
merged 1 commit into from
Dec 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
86 changes: 46 additions & 40 deletions config/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,20 @@
* @license https://opensource.org/licenses/mit-license.php MIT License
*/

/*
* This file is loaded by your src/Application.php bootstrap method.
* Feel free to extend/extract parts of the bootstrap process into your own files
* to suit your needs/preferences.
*/

/*
* Configure paths required to find CakePHP + general filepath constants
*/
require __DIR__ . DIRECTORY_SEPARATOR . 'paths.php';

/*
* Bootstrap CakePHP.
*
* Does the various bits of setup that CakePHP needs to do.
* This includes:
*
* - Registering the CakePHP autoloader.
* - Setting the default application paths.
* Bootstrap CakePHP
* Currently all this does is initialize the router (without loading your routes)
*/
require CORE_PATH . 'config' . DS . 'bootstrap.php';

Expand All @@ -44,8 +45,8 @@
use Cake\Routing\Router;
use Cake\Utility\Security;

/**
* Load global functions.
/*
* Load global functions for collections, translations, debugging etc.
*/
require CAKE . 'functions.php';

Expand All @@ -72,12 +73,11 @@
// }

/*
* Read configuration file and inject configuration into various
* CakePHP classes.
* Initializes default Config store and loads the main configuration file (app.php)
*
* By default there is only one configuration file. It is often a good
* idea to create multiple configuration files, and separate the configuration
* that changes from configuration that does not. This makes deployment simpler.
* CakePHP contains 2 configuration files after project creation:
* - `config/app.php` for the default application configuration.
* - `config/app_local.php` for environment specific configuration.
*/
try {
Configure::config('default', new PhpConfig());
Expand All @@ -95,8 +95,7 @@
}

/*
* When debug = true the metadata cache should only last
* for a short time.
* When debug = true the metadata cache should only last for a short time.
*/
if (Configure::read('debug')) {
Configure::write('Cache._cake_model_.duration', '+2 minutes');
Expand Down Expand Up @@ -127,15 +126,26 @@
(new ExceptionTrap(Configure::read('Error')))->register();

/*
* Include the CLI bootstrap overrides.
* CLI/Command specific configuration.
*/
if (PHP_SAPI === 'cli') {
require CONFIG . 'bootstrap_cli.php';
// Set the fullBaseUrl to allow URLs to be generated in commands.
// This is useful when sending email from commands.
// Configure::write('App.fullBaseUrl', php_uname('n'));

// Set logs to different files so they don't have permission conflicts.
if (Configure::check('Log.debug')) {
Configure::write('Log.debug.file', 'cli-debug');
}
if (Configure::check('Log.error')) {
Configure::write('Log.error.file', 'cli-error');
}
}

/*
* Set the full base URL.
* This URL is used as the base of all absolute links.
* Can be very useful for CLI/Commandline applications.
*/
$fullBaseUrl = Configure::read('App.fullBaseUrl');
if (!$fullBaseUrl) {
Expand Down Expand Up @@ -165,6 +175,10 @@
}
unset($fullBaseUrl);

/*
* Apply the loaded configuration settings to their respective systems.
* This will also remove the loaded config data from memory.
*/
Cache::setConfig(Configure::consume('Cache'));
ConnectionManager::setConfig(Configure::consume('Datasources'));
TransportFactory::setConfig(Configure::consume('EmailTransport'));
Expand All @@ -191,37 +205,29 @@
/*
* You can enable default locale format parsing by adding calls
* to `useLocaleParser()`. This enables the automatic conversion of
* locale specific date formats. For details see
* locale specific date formats when processing request data. For details see
* @link https://book.cakephp.org/5/en/core-libraries/internationalization-and-localization.html#parsing-localized-datetime-data
*/
// \Cake\Database\TypeFactory::build('time')
// ->useLocaleParser();
// \Cake\Database\TypeFactory::build('date')
// ->useLocaleParser();
// \Cake\Database\TypeFactory::build('datetime')
// ->useLocaleParser();
// \Cake\Database\TypeFactory::build('timestamp')
// ->useLocaleParser();
// \Cake\Database\TypeFactory::build('datetimefractional')
// ->useLocaleParser();
// \Cake\Database\TypeFactory::build('timestampfractional')
// ->useLocaleParser();
// \Cake\Database\TypeFactory::build('datetimetimezone')
// ->useLocaleParser();
// \Cake\Database\TypeFactory::build('timestamptimezone')
// ->useLocaleParser();
// \Cake\Database\TypeFactory::build('time')->useLocaleParser();
// \Cake\Database\TypeFactory::build('date')->useLocaleParser();
// \Cake\Database\TypeFactory::build('datetime')->useLocaleParser();
// \Cake\Database\TypeFactory::build('timestamp')->useLocaleParser();
// \Cake\Database\TypeFactory::build('datetimefractional')->useLocaleParser();
// \Cake\Database\TypeFactory::build('timestampfractional')->useLocaleParser();
// \Cake\Database\TypeFactory::build('datetimetimezone')->useLocaleParser();
// \Cake\Database\TypeFactory::build('timestamptimezone')->useLocaleParser();

/*
* Custom Inflector rules, can be set to correctly pluralize or singularize
* table, model, controller names or whatever other string is passed to the
* inflection functions.
*/
//Inflector::rules('plural', ['/^(inflect)or$/i' => '\1ables']);
//Inflector::rules('irregular', ['red' => 'redlings']);
//Inflector::rules('uninflected', ['dontinflectme']);
// \Cake\Utility\Inflector::rules('plural', ['/^(inflect)or$/i' => '\1ables']);
// \Cake\Utility\Inflector::rules('irregular', ['red' => 'redlings']);
// \Cake\Utility\Inflector::rules('uninflected', ['dontinflectme']);

// set a custom date and time format
// see https://book.cakephp.org/5/en/core-libraries/time.html#setting-the-default-locale-and-format-string
// and https://unicode-org.github.io/icu/userguide/format_parse/datetime/#datetime-format-syntax
//\Cake\I18n\Date::setToStringFormat('dd.MM.yyyy');
//\Cake\I18n\Time::setToStringFormat('dd.MM.yyyy HH:mm');
// \Cake\I18n\Date::setToStringFormat('dd.MM.yyyy');
// \Cake\I18n\Time::setToStringFormat('dd.MM.yyyy HH:mm');
35 changes: 0 additions & 35 deletions config/bootstrap_cli.php

This file was deleted.