Skip to content

Commit 55c9f39

Browse files
committed
Update with upgrade tool.
1 parent f532c7c commit 55c9f39

15 files changed

Lines changed: 186 additions & 172 deletions

‎config/bootstrap.php‎

Lines changed: 65 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
<?php
2+
declare(strict_types=1);
3+
24
/**
35
* CakePHP(tm) : Rapid Development Framework (https://cakephp.org)
46
* Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
@@ -30,33 +32,39 @@
3032
require CORE_PATH . 'config' . DS . 'bootstrap.php';
3133

3234
use Cake\Cache\Cache;
33-
use Cake\Console\ConsoleErrorHandler;
34-
use Cake\Core\App;
3535
use Cake\Core\Configure;
3636
use Cake\Core\Configure\Engine\PhpConfig;
37-
use Cake\Core\Plugin;
38-
use Cake\Database\Type;
3937
use Cake\Datasource\ConnectionManager;
38+
use Cake\Error\ConsoleErrorHandler;
4039
use Cake\Error\ErrorHandler;
4140
use Cake\Http\ServerRequest;
4241
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;
4545
use Cake\Utility\Security;
4646

47-
/**
48-
* Read .env file if APP_NAME is not set.
47+
/*
48+
* See https://github.com/josegonzalez/php-dotenv for API details.
4949
*
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+
// }
6068

6169
/*
6270
* Read configuration file and inject configuration into various
@@ -74,11 +82,12 @@
7482
}
7583

7684
/*
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.
8087
*/
81-
//Configure::load('app_local', 'default');
88+
if (file_exists(CONFIG . 'app_local.php')) {
89+
Configure::load('app_local', 'default');
90+
}
8291

8392
/*
8493
* When debug = true the metadata cache should only last
@@ -87,14 +96,15 @@
8796
if (Configure::read('debug')) {
8897
Configure::write('Cache._cake_model_.duration', '+2 minutes');
8998
Configure::write('Cache._cake_core_.duration', '+2 minutes');
99+
// disable router cache during development
100+
Configure::write('Cache._cake_routes_.duration', '+2 seconds');
90101
}
91102

92103
/*
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.
95105
* Check http://php.net/manual/en/timezones.php for list of valid timezone strings.
96106
*/
97-
date_default_timezone_set('UTC');
107+
date_default_timezone_set(Configure::read('App.defaultTimezone'));
98108

99109
/*
100110
* Configure the mbstring extension to use the correct encoding.
@@ -127,36 +137,32 @@
127137
/*
128138
* Set the full base URL.
129139
* 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.
132140
*/
133-
if (!Configure::read('App.fullBaseUrl')) {
141+
$fullBaseUrl = Configure::read('App.fullBaseUrl');
142+
if (!$fullBaseUrl) {
134143
$s = null;
135144
if (env('HTTPS')) {
136145
$s = 's';
137146
}
138147

139148
$httpHost = env('HTTP_HOST');
140149
if (isset($httpHost)) {
141-
Configure::write('App.fullBaseUrl', 'http' . $s . '://' . $httpHost);
150+
$fullBaseUrl = 'http' . $s . '://' . $httpHost;
142151
}
143152
unset($httpHost, $s);
144153
}
154+
if ($fullBaseUrl) {
155+
Router::fullBaseUrl($fullBaseUrl);
156+
}
157+
unset($fullBaseUrl);
145158

146159
Cache::setConfig(Configure::consume('Cache'));
147160
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'));
150163
Log::setConfig(Configure::consume('Log'));
151164
Security::setSalt(Configure::consume('Security.salt'));
152165

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-
160166
/*
161167
* Setup detectors for mobile and tablet.
162168
*/
@@ -172,21 +178,31 @@
172178
});
173179

174180
/*
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.
176184
*
177185
* You can enable default locale format parsing by adding calls
178186
* to `useLocaleParser()`. This enables the automatic conversion of
179187
* 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();
190206

191207
/*
192208
* Custom Inflector rules, can be set to correctly pluralize or singularize
@@ -197,21 +213,3 @@
197213
//Inflector::rules('irregular', ['red' => 'redlings']);
198214
//Inflector::rules('uninflected', ['dontinflectme']);
199215
//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-
}

‎config/bootstrap_cli.php‎

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
<?php
2+
declare(strict_types=1);
3+
24
/**
35
* CakePHP(tm) : Rapid Development Framework (https://cakephp.org)
46
* Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
@@ -12,11 +14,10 @@
1214
* @since 3.0.0
1315
* @license https://opensource.org/licenses/mit-license.php MIT License
1416
*/
17+
1518
use Cake\Core\Configure;
16-
use Cake\Core\Exception\MissingPluginException;
17-
use Cake\Core\Plugin;
1819

19-
/**
20+
/*
2021
* Additional bootstrapping and configuration for CLI environments should
2122
* be put here.
2223
*/
@@ -28,11 +29,3 @@
2829
// Set logs to different files so they don't have permission conflicts.
2930
Configure::write('Log.debug.file', 'cli-debug');
3031
Configure::write('Log.error.file', 'cli-error');
31-
32-
try {
33-
Plugin::load('Bake');
34-
} catch (MissingPluginException $e) {
35-
// Do not halt if the plugin is missing
36-
}
37-
38-
Plugin::load('Migrations');

‎config/paths.php‎

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,73 +12,82 @@
1212
* @license MIT License (https://opensource.org/licenses/mit-license.php)
1313
*/
1414

15-
/**
15+
/*
1616
* Use the DS to separate the directories in other defines
1717
*/
1818
if (!defined('DS')) {
1919
define('DS', DIRECTORY_SEPARATOR);
2020
}
2121

22-
/**
22+
/*
2323
* These defines should only be edited if you have cake installed in
2424
* a directory layout other than the way it is distributed.
2525
* When using custom settings be sure to use the DS and do not add a trailing DS.
2626
*/
2727

28-
/**
28+
/*
2929
* The full path to the directory which holds "src", WITHOUT a trailing DS.
3030
*/
3131
define('ROOT', dirname(__DIR__));
3232

33-
/**
33+
/*
3434
* The actual directory name for the application directory. Normally
3535
* named 'src'.
3636
*/
3737
define('APP_DIR', 'src');
3838

39-
/**
39+
/*
4040
* Path to the application's directory.
4141
*/
4242
define('APP', ROOT . DS . APP_DIR . DS);
4343

44-
/**
44+
/*
4545
* Path to the config directory.
4646
*/
4747
define('CONFIG', ROOT . DS . 'config' . DS);
4848

49-
/**
49+
/*
5050
* File path to the webroot directory.
51+
*
52+
* To derive your webroot from your webserver change this to:
53+
*
54+
* `define('WWW_ROOT', rtrim($_SERVER['DOCUMENT_ROOT'], DS) . DS);`
5155
*/
5256
define('WWW_ROOT', ROOT . DS . 'webroot' . DS);
5357

54-
/**
58+
/*
5559
* Path to the tests directory.
5660
*/
5761
define('TESTS', ROOT . DS . 'tests' . DS);
5862

59-
/**
63+
/*
6064
* Path to the temporary files directory.
6165
*/
6266
define('TMP', ROOT . DS . 'tmp' . DS);
6367

64-
/**
68+
/*
6569
* Path to the logs directory.
6670
*/
6771
define('LOGS', ROOT . DS . 'logs' . DS);
6872

69-
/**
73+
/*
7074
* Path to the cache files directory. It can be shared between hosts in a multi-server setup.
7175
*/
7276
define('CACHE', TMP . 'cache' . DS);
7377

78+
/**
79+
* Path to the resources directory.
80+
*/
81+
define('RESOURCES', ROOT . DS . 'resources' . DS);
82+
7483
/**
7584
* The absolute path to the "cake" directory, WITHOUT a trailing DS.
7685
*
7786
* CakePHP should always be installed with composer, so look there.
7887
*/
7988
define('CAKE_CORE_INCLUDE_PATH', ROOT . DS . 'vendor' . DS . 'cakephp' . DS . 'cakephp');
8089

81-
/**
90+
/*
8291
* Path to the cake directory.
8392
*/
8493
define('CORE_PATH', CAKE_CORE_INCLUDE_PATH . DS);

‎config/requirements.php‎

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,20 +20,27 @@
2020
/*
2121
* You can remove this if you are confident that your PHP version is sufficient.
2222
*/
23-
if (version_compare(PHP_VERSION, '5.6.0') < 0) {
24-
trigger_error('Your PHP version must be equal or higher than 5.6.0 to use CakePHP.' . PHP_EOL, E_USER_ERROR);
23+
if (version_compare(PHP_VERSION, '7.2.0') < 0) {
24+
trigger_error('Your PHP version must be equal or higher than 7.2.0 to use CakePHP.', E_USER_ERROR);
2525
}
2626

2727
/*
2828
* You can remove this if you are confident you have intl installed.
2929
*/
3030
if (!extension_loaded('intl')) {
31-
trigger_error('You must enable the intl extension to use CakePHP.' . PHP_EOL, E_USER_ERROR);
31+
trigger_error('You must enable the intl extension to use CakePHP.', E_USER_ERROR);
32+
}
33+
34+
/*
35+
* You can remove this if you are confident you have proper version of intl.
36+
*/
37+
if (version_compare(INTL_ICU_VERSION, '50.1', '<')) {
38+
trigger_error('ICU >= 50.1 is needed to use CakePHP. Please update the `libicu` package of your system.' . PHP_EOL, E_USER_ERROR);
3239
}
3340

3441
/*
3542
* You can remove this if you are confident you have mbstring installed.
3643
*/
3744
if (!extension_loaded('mbstring')) {
38-
trigger_error('You must enable the mbstring extension to use CakePHP.' . PHP_EOL, E_USER_ERROR);
45+
trigger_error('You must enable the mbstring extension to use CakePHP.', E_USER_ERROR);
3946
}

‎src/Application.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ class Application extends BaseApplication
3434
* @param \Cake\Http\MiddlewareQueue $middlewareQueue The middleware queue to setup.
3535
* @return \Cake\Http\MiddlewareQueue The updated middleware queue.
3636
*/
37-
public function middleware($middlewareQueue)
37+
public function middleware($middlewareQueue): \Cake\Http\MiddlewareQueue
3838
{
3939
$middlewareQueue
4040
// Catch any exceptions in the lower layers,

0 commit comments

Comments
 (0)