I get an error with the tool to upgrade cakePHP 2 to 3

Hi,

I have an application made with CakePHP2.
I would like to upgrade to CakePHP3.

The server environment is as follows.
OS:Amazon Linux2
PHP 7.2.13 (cli) (built: Jan 8 2019 18:59:48) ( NTS )

Following the explanation, the work was carried out.
https://book.cakephp.org/3.0/ja/upgrade-tool.html

The installation log is as follows.

$ composer install
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 46 installs, 0 updates, 0 removals
  - Installing cakephp/plugin-installer (1.1.0): Downloading (100%)
  - Installing mobiledetect/mobiledetectlib (2.8.33): Downloading (100%)
  - Installing psr/http-message (1.0.1): Downloading (100%)
  - Installing zendframework/zend-diactoros (1.8.6): Downloading (100%)
  - Installing psr/simple-cache (1.0.1): Downloading (100%)
  - Installing psr/log (1.1.0): Downloading (100%)
  - Installing aura/intl (3.0.0): Downloading (100%)
  - Installing cakephp/chronos (1.2.3): Downloading (100%)
  - Installing cakephp/cakephp (3.7.3): Downloading (100%)
  - Installing symfony/polyfill-ctype (v1.10.0): Downloading (100%)
  - Installing symfony/yaml (v4.2.2): Downloading (100%)
  - Installing symfony/polyfill-mbstring (v1.10.0): Downloading (100%)
  - Installing symfony/contracts (v1.0.2): Downloading (100%)
  - Installing symfony/console (v4.2.2): Downloading (100%)
  - Installing symfony/filesystem (v4.2.2): Downloading (100%)
  - Installing symfony/config (v4.2.2): Downloading (100%)
  - Installing robmorgan/phinx (0.10.6): Downloading (100%)
  - Installing cakephp/migrations (2.1.0): Downloading (100%)
  - Installing cakephp/app (3.7.1): Downloading (100%)
  - Installing sebastian/version (2.0.1): Downloading (100%)
  - Installing sebastian/resource-operations (2.0.1): Downloading (100%)
  - Installing sebastian/object-reflector (1.1.1): Downloading (100%)
  - Installing sebastian/recursion-context (3.0.0): Downloading (100%)
  - Installing sebastian/object-enumerator (3.0.3): Downloading (100%)
  - Installing sebastian/global-state (3.0.0): Downloading (100%)
  - Installing sebastian/exporter (3.1.0): Downloading (100%)
  - Installing sebastian/environment (4.1.0): Downloading (100%)
  - Installing sebastian/diff (3.0.1): Downloading (100%)
  - Installing sebastian/comparator (3.0.2): Downloading (100%)
  - Installing phpunit/php-timer (2.0.0): Downloading (100%)
  - Installing phpunit/php-text-template (1.2.1): Downloading (100%)
  - Installing phpunit/php-file-iterator (2.0.2): Downloading (100%)
  - Installing theseer/tokenizer (1.1.0): Downloading (100%)
  - Installing sebastian/code-unit-reverse-lookup (1.0.1): Downloading (100%)
  - Installing phpunit/php-token-stream (3.0.1): Downloading (100%)
  - Installing phpunit/php-code-coverage (7.0.1): Downloading (100%)
  - Installing doctrine/instantiator (1.1.0): Downloading (100%)
  - Installing webmozart/assert (1.4.0): Downloading (100%)
  - Installing phpdocumentor/reflection-common (1.0.1): Downloading (100%)
  - Installing phpdocumentor/type-resolver (0.4.0): Downloading (100%)
  - Installing phpdocumentor/reflection-docblock (4.3.0): Downloading (100%)
  - Installing phpspec/prophecy (1.8.0): Downloading (100%)
  - Installing phar-io/version (2.0.1): Downloading (100%)
  - Installing phar-io/manifest (1.0.3): Downloading (100%)
  - Installing myclabs/deep-copy (1.8.1): Downloading (100%)
  - Installing phpunit/phpunit (8.0.0): Downloading (100%)
cakephp/cakephp suggests installing lib-ICU (The intl PHP library, to use Text::transliterate() or Text::slug())
symfony/contracts suggests installing psr/cache (When using the Cache contracts)
symfony/contracts suggests installing psr/container (When using the Service contracts)
symfony/contracts suggests installing symfony/cache-contracts-implementation
symfony/contracts suggests installing symfony/service-contracts-implementation
symfony/contracts suggests installing symfony/translation-contracts-implementation
symfony/console suggests installing psr/log-implementation (For using the console logger)
symfony/console suggests installing symfony/event-dispatcher
symfony/console suggests installing symfony/lock
symfony/console suggests installing symfony/process
cakephp/migrations suggests installing cakephp/bake (Required if you want to generate migrations.)
cakephp/app suggests installing markstory/asset_compress (An asset compression plugin which provides file concatenation and a flexible filter system for preprocessing and minification.)
cakephp/app suggests installing dereuromark/cakephp-ide-helper (After baking your code, this keeps your annotations in sync with the code evolving from there on for maximum IDE and PHPStan compatibility.)
sebastian/global-state suggests installing ext-uopz (*)
sebastian/environment suggests installing ext-posix (*)
phpunit/php-code-coverage suggests installing ext-xdebug (^2.6.1)
phpunit/phpunit suggests installing phpunit/php-invoker (^2.0)
phpunit/phpunit suggests installing ext-soap (*)
phpunit/phpunit suggests installing ext-xdebug (*)
Writing lock file
Generating autoload files
> Cake\Composer\Installer\PluginInstaller::postAutoloadDump

The error is as follows.

$ bin/cake upgrade --help
PHP Deprecated:  PHP configuration files like "app.php" should not set `$config`. Instead return an array. - /var/www/html/upgrade/vendor/cakephp/cakephp/src/Core/Configure.php, line: 343
 You can disable deprecation warnings by setting `Error.errorLevel` to `E_ALL & ~E_USER_DEPRECATED` in your config/app.php. in /var/www/html/upgrade/vendor/cakephp/cakephp/src/Core/functions.php on line 311
Deprecated Error: Cake\Cache\Cache::config() is deprecated. Use setConfig()/getConfig() instead. - /var/www/html/upgrade/config/bootstrap.php, line: 121
 You can disable deprecation warnings by setting `Error.errorLevel` to `E_ALL & ~E_USER_DEPRECATED` in your config/app.php. in [/var/www/html/upgrade/vendor/cakephp/cakephp/src/Core/functions.php, line 311]

Deprecated Error: Cake\Datasource\ConnectionManager::config() is deprecated. Use setConfig()/getConfig() instead. - /var/www/html/upgrade/config/bootstrap.php, line: 122
 You can disable deprecation warnings by setting `Error.errorLevel` to `E_ALL & ~E_USER_DEPRECATED` in your config/app.php. in [/var/www/html/upgrade/vendor/cakephp/cakephp/src/Core/functions.php, line 311]

Deprecated Error: Use Cake\Mailer\Email instead of Cake\Network\Email\Email. - /var/www/html/upgrade/vendor/composer/ClassLoader.php, line: 444
 You can disable deprecation warnings by setting `Error.errorLevel` to `E_ALL & ~E_USER_DEPRECATED` in your config/app.php. in [/var/www/html/upgrade/vendor/cakephp/cakephp/src/Core/functions.php, line 311]

Deprecated Error: Email::configTransport() is deprecated. Use TransportFactory::setConfig() or TransportFactory::getConfig() instead. - /var/www/html/upgrade/config/bootstrap.php, line: 123
 You can disable deprecation warnings by setting `Error.errorLevel` to `E_ALL & ~E_USER_DEPRECATED` in your config/app.php. in [/var/www/html/upgrade/vendor/cakephp/cakephp/src/Core/functions.php, line 311]

Exception: If config is null, key must be an array. in [/var/www/html/upgrade/vendor/cakephp/cakephp/src/Core/StaticConfigTrait.php, line 79]

I did the following work.

change config/app.php

'Error' => [
        #'errorLevel' => E_ALL & ~E_DEPRECATED,
        'errorLevel' => E_ALL & ~E_USER_DEPRECATED,  
        'exceptionRenderer' => 'Cake\Error\ExceptionRenderer',
        'skipLog' => [],
        'log' => true,
        'trace' => true,
],

The errors displayed after that are as follows.

$ bin/cake upgrade --help
PHP Deprecated:  PHP configuration files like "app.php" should not set `$config`. Instead return an array. - /var/www/html/upgrade/vendor/cakephp/cakephp/src/Core/Configure.php, line: 343
 You can disable deprecation warnings by setting `Error.errorLevel` to `E_ALL & ~E_USER_DEPRECATED` in your config/app.php. in /var/www/html/upgrade/vendor/cakephp/cakephp/src/Core/functions.php on line 311
Exception: If config is null, key must be an array. in [/var/www/html/upgrade/vendor/cakephp/cakephp/src/Core/StaticConfigTrait.php, line 79]

How can I deal with it?

Did you try changing config/app.php to return an array instead of setting $config? That warning will be issued by whatever is reading that file, before it gets parsed and the actual error level set from it.

I made changes to config / app.php.
The only change is errorLevel.

Besides, there is no difference from the original file.

Do I need to change config / app.php to run the upgrade script?

I don’t have much experience with the upgrade script itself, but making that change toconfig/app.php is something you’ll need to do eventually, and it seems it’ll fix this warning for you, so may as well give it a try.

Thank you for your reply.

As you advise, I’d like to change app.php, but if the outgoing error is

PHP configuration files like "app.php" should not set `$ config`

Since the original app.php is $ config from the first description, I do not know how to change it.

I will search for information about app.php.

Instead of

$config = [ ... ];

try just changing to

return [ … ];

That should be all you need.

As you made your advice, I made changes and the error disappeared.

vendor/cakephp/app/config/app.default.php

Looking at this file, as pointed out

return [ … ];

It was processing starting from.

Also, an error occurred due to absence of EmailTransport setting in config/app.php.
Therefore, referring to app.default.php, when setting was added, everything worked properly.

Thank you very much.