updating cakephp apps
[feisty_meow.git] / production / example_apps / zippy_maps / config / bootstrap.php
1 <?php
2 /**
3  * CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
4  * Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
5  *
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.
9  *
10  * @copyright     Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
11  * @link          http://cakephp.org CakePHP(tm) Project
12  * @since         0.10.8
13  * @license       http://www.opensource.org/licenses/mit-license.php MIT License
14  */
15
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);
19 }
20
21 /*
22  *  You can remove this if you are confident you have intl installed.
23  */
24 if (!extension_loaded('intl')) {
25     trigger_error('You must enable the intl extension to use CakePHP.', E_USER_ERROR);
26 }
27
28 /*
29  * You can remove this if you are confident you have mbstring installed.
30  */
31 if (!extension_loaded('mbstring')) {
32     trigger_error('You must enable the mbstring extension to use CakePHP.', E_USER_ERROR);
33 }
34
35 /*
36  * Configure paths required to find CakePHP + general filepath
37  * constants
38  */
39 require __DIR__ . '/paths.php';
40
41 /*
42  * Bootstrap CakePHP.
43  *
44  * Does the various bits of setup that CakePHP needs to do.
45  * This includes:
46  *
47  * - Registering the CakePHP autoloader.
48  * - Setting the default application paths.
49  */
50 require CORE_PATH . 'config' . DS . 'bootstrap.php';
51
52 use Cake\Cache\Cache;
53 use Cake\Console\ConsoleErrorHandler;
54 use Cake\Core\App;
55 use Cake\Core\Configure;
56 use Cake\Core\Configure\Engine\PhpConfig;
57 use Cake\Core\Plugin;
58 use Cake\Database\Type;
59 use Cake\Datasource\ConnectionManager;
60 use Cake\Error\ErrorHandler;
61 use Cake\Log\Log;
62 use Cake\Mailer\Email;
63 use Cake\Network\Request;
64 use Cake\Utility\Inflector;
65 use Cake\Utility\Security;
66
67 /*
68  * Read configuration file and inject configuration into various
69  * CakePHP classes.
70  *
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.
74  */
75 try {
76     Configure::config('default', new PhpConfig());
77     Configure::load('app', 'default', false);
78
79     // load our google maps api config file.
80     Configure::load('config_google', 'default');
81
82 } catch (\Exception $e) {
83     exit($e->getMessage() . "\n");
84 }
85
86 /*
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.
90  */
91 //Configure::load('app_local', 'default');
92
93 /*
94  * When debug = true the metadata cache should only last
95  * for a short time.
96  */
97 if (Configure::read('debug')) {
98     Configure::write('Cache._cake_model_.duration', '+2 minutes');
99     Configure::write('Cache._cake_core_.duration', '+2 minutes');
100 }
101
102 /*
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.
105  */
106 date_default_timezone_set('UTC');
107
108 /*
109  * Configure the mbstring extension to use the correct encoding.
110  */
111 mb_internal_encoding(Configure::read('App.encoding'));
112
113 /*
114  * Set the default locale. This controls how dates, number and currency is
115  * formatted and sets the default language to use for translations.
116  */
117 ini_set('intl.default_locale', Configure::read('App.defaultLocale'));
118
119 /*
120  * Register application error and exception handlers.
121  */
122 $isCli = PHP_SAPI === 'cli';
123 if ($isCli) {
124     (new ConsoleErrorHandler(Configure::read('Error')))->register();
125 } else {
126     (new ErrorHandler(Configure::read('Error')))->register();
127 }
128
129 /*
130  * Include the CLI bootstrap overrides.
131  */
132 if ($isCli) {
133     require __DIR__ . '/bootstrap_cli.php';
134 }
135
136 /*
137  * Set the full base URL.
138  * This URL is used as the base of all absolute links.
139  *
140  * If you define fullBaseUrl in your config file you can remove this.
141  */
142 if (!Configure::read('App.fullBaseUrl')) {
143     $s = null;
144     if (env('HTTPS')) {
145         $s = 's';
146     }
147
148     $httpHost = env('HTTP_HOST');
149     if (isset($httpHost)) {
150         Configure::write('App.fullBaseUrl', 'http' . $s . '://' . $httpHost);
151     }
152     unset($httpHost, $s);
153 }
154
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'));
162
163 /*
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
167  */
168 //Security::engine(new \Cake\Utility\Crypto\Mcrypt());
169
170 /*
171  * Setup detectors for mobile and tablet.
172  */
173 Request::addDetector('mobile', function ($request) {
174     $detector = new \Detection\MobileDetect();
175
176     return $detector->isMobile();
177 });
178 Request::addDetector('tablet', function ($request) {
179     $detector = new \Detection\MobileDetect();
180
181     return $detector->isTablet();
182 });
183
184 /*
185  * Enable immutable time objects in the ORM.
186  *
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
191  */
192 Type::build('time')
193     ->useImmutable();
194 Type::build('date')
195     ->useImmutable();
196 Type::build('datetime')
197     ->useImmutable();
198 Type::build('timestamp')
199     ->useImmutable();
200         
201         /*
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.
205  */
206         // Inflector::rules('plural', ['/^(inflect)or$/i' => '\1ables']);
207         // Inflector::rules('irregular', ['red' => 'redlings']);
208         // Inflector::rules('uninflected', ['dontinflectme']);
209         // Inflector::rules('transliteration', ['/å/' => 'aa']);
210         
211 /*
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
215  *
216  * Plugin::loadAll(); // Loads all plugins at once
217  * Plugin::load('Migrations'); //Loads a single plugin named Migrations
218  *
219  */
220         
221 /*
222  * Only try to load DebugKit in development mode
223  * Debug Kit should not be installed on a production system
224  */
225 if (Configure::read ( 'debug' )) {
226         Plugin::load ( 'DebugKit', [ 
227                         'bootstrap' => true 
228         ] );
229 }
230
231 Plugin::load ( 'Migrations' );
232
233 // hoist up the geocoder and maps support, matey.
234 Plugin::load ( 'Geo', [ 
235                 'bootstrap' => true 
236 ] );
237
238 Plugin::load ( 'DebugKit' );
239
240
241 Plugin::load('Avmaps', ['bootstrap' => false, 'routes' => true]);
242
243