3 * CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
4 * Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
6 * Licensed under The MIT License
7 * For full copyright and license information, please see the LICENSE.txt
8 * Redistributions of files must retain the above copyright notice.
10 * @copyright Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
11 * @link http://cakephp.org CakePHP(tm) Project
13 * @license http://www.opensource.org/licenses/mit-license.php MIT License
16 // You can remove this if you are confident that your PHP version is sufficient.
17 if (version_compare(PHP_VERSION, '5.6.0') < 0) {
18 trigger_error('Your PHP version must be equal or higher than 5.6.0 to use CakePHP.', E_USER_ERROR);
22 * You can remove this if you are confident you have intl installed.
24 if (!extension_loaded('intl')) {
25 trigger_error('You must enable the intl extension to use CakePHP.', E_USER_ERROR);
29 * You can remove this if you are confident you have mbstring installed.
31 if (!extension_loaded('mbstring')) {
32 trigger_error('You must enable the mbstring extension to use CakePHP.', E_USER_ERROR);
36 * Configure paths required to find CakePHP + general filepath
39 require __DIR__ . '/paths.php';
44 * Does the various bits of setup that CakePHP needs to do.
47 * - Registering the CakePHP autoloader.
48 * - Setting the default application paths.
50 require CORE_PATH . 'config' . DS . 'bootstrap.php';
53 use Cake\Console\ConsoleErrorHandler;
55 use Cake\Core\Configure;
56 use Cake\Core\Configure\Engine\PhpConfig;
58 use Cake\Database\Type;
59 use Cake\Datasource\ConnectionManager;
60 use Cake\Error\ErrorHandler;
62 use Cake\Mailer\Email;
63 use Cake\Network\Request;
64 use Cake\Utility\Inflector;
65 use Cake\Utility\Security;
68 * Read configuration file and inject configuration into various
71 * By default there is only one configuration file. It is often a good
72 * idea to create multiple configuration files, and separate the configuration
73 * that changes from configuration that does not. This makes deployment simpler.
76 Configure::config('default', new PhpConfig());
77 Configure::load('app', 'default', false);
79 // load our google maps api config file.
80 Configure::load('config_google', 'default');
82 } catch (\Exception $e) {
83 exit($e->getMessage() . "\n");
87 * Load an environment local configuration file.
88 * You can use a file like app_local.php to provide local overrides to your
89 * shared configuration.
91 //Configure::load('app_local', 'default');
94 * When debug = true the metadata cache should only last
97 if (Configure::read('debug')) {
98 Configure::write('Cache._cake_model_.duration', '+2 minutes');
99 Configure::write('Cache._cake_core_.duration', '+2 minutes');
103 * Set server timezone to UTC. You can change it to another timezone of your
104 * choice but using UTC makes time calculations / conversions easier.
106 date_default_timezone_set('UTC');
109 * Configure the mbstring extension to use the correct encoding.
111 mb_internal_encoding(Configure::read('App.encoding'));
114 * Set the default locale. This controls how dates, number and currency is
115 * formatted and sets the default language to use for translations.
117 ini_set('intl.default_locale', Configure::read('App.defaultLocale'));
120 * Register application error and exception handlers.
122 $isCli = PHP_SAPI === 'cli';
124 (new ConsoleErrorHandler(Configure::read('Error')))->register();
126 (new ErrorHandler(Configure::read('Error')))->register();
130 * Include the CLI bootstrap overrides.
133 require __DIR__ . '/bootstrap_cli.php';
137 * Set the full base URL.
138 * This URL is used as the base of all absolute links.
140 * If you define fullBaseUrl in your config file you can remove this.
142 if (!Configure::read('App.fullBaseUrl')) {
148 $httpHost = env('HTTP_HOST');
149 if (isset($httpHost)) {
150 Configure::write('App.fullBaseUrl', 'http' . $s . '://' . $httpHost);
152 unset($httpHost, $s);
155 Cache::setConfig(Configure::consume('Cache'));
156 ConnectionManager::setConfig(Configure::consume('Datasources'));
157 Email::setConfigTransport(Configure::consume('EmailTransport'));
158 //TransportFactory::setConfig(Configure::consume('EmailTransport'));
159 Email::setConfig(Configure::consume('Email'));
160 Log::setConfig(Configure::consume('Log'));
161 Security::salt(Configure::consume('Security.salt'));
164 * The default crypto extension in 3.0 is OpenSSL.
165 * If you are migrating from 2.x uncomment this code to
166 * use a more compatible Mcrypt based implementation
168 //Security::engine(new \Cake\Utility\Crypto\Mcrypt());
171 * Setup detectors for mobile and tablet.
173 Request::addDetector('mobile', function ($request) {
174 $detector = new \Detection\MobileDetect();
176 return $detector->isMobile();
178 Request::addDetector('tablet', function ($request) {
179 $detector = new \Detection\MobileDetect();
181 return $detector->isTablet();
185 * Enable immutable time objects in the ORM.
187 * You can enable default locale format parsing by adding calls
188 * to `useLocaleParser()`. This enables the automatic conversion of
189 * locale specific date formats. For details see
190 * @link http://book.cakephp.org/3.0/en/core-libraries/internationalization-and-localization.html#parsing-localized-datetime-data
196 Type::build('datetime')
198 Type::build('timestamp')
202 * Custom Inflector rules, can be set to correctly pluralize or singularize
203 * table, model, controller names or whatever other string is passed to the
204 * inflection functions.
206 // Inflector::rules('plural', ['/^(inflect)or$/i' => '\1ables']);
207 // Inflector::rules('irregular', ['red' => 'redlings']);
208 // Inflector::rules('uninflected', ['dontinflectme']);
209 // Inflector::rules('transliteration', ['/å/' => 'aa']);
212 * Plugins need to be loaded manually, you can either load them one by one or all of them in a single call
213 * Uncomment one of the lines below, as you need. make sure you read the documentation on Plugin to use more
214 * advanced ways of loading plugins
216 * Plugin::loadAll(); // Loads all plugins at once
217 * Plugin::load('Migrations'); //Loads a single plugin named Migrations
222 * Only try to load DebugKit in development mode
223 * Debug Kit should not be installed on a production system
225 if (Configure::read ( 'debug' )) {
226 Plugin::load ( 'DebugKit', [
231 Plugin::load ( 'Migrations' );
233 // hoist up the geocoder and maps support, matey.
234 Plugin::load ( 'Geo', [
238 Plugin::load ( 'DebugKit' );
241 Plugin::load('Avmaps', ['bootstrap' => false, 'routes' => true]);