Yii2.0.12 upgrade to PHP7.2

Posted by eerikk2 on Sun, 10 Nov 2019 20:37:57 +0100

Let's talk about the PHP running environment of the Yii framework.

Yii 2.0.12 uses the \ yii\base\Object class, and the Object as the class name PHP7.2 reports an error.

The minimum available version of Yii2 for PHP7.2 is 2.0.13.

Provides several ways to upgrade.

  1. The project uses Composer to manage bower and npm front-end resources.

Install the latest version of composer asset plugin

composer global require "fxp/composer-asset-plugin"

Specify class library updates

composer update yiisoft/yii2 yiisoft/yii2-composer bower-asset/jquery.inputmask

Composer records are as follows

Loading composer repositories with package information
Updating dependencies (including require-dev)
Reading bower.json of bower-asset/yii2-pjax (2.0.7.1)GitHub API limit (60 calls/hr) is exhausted, could not fetch https://api.github.com/repos/yiisoft/jquery-pjax/commits/aef7b953107264f00234902a3880eb50dafc48be. Create a GitHub OAuth token to go over the API rate limit. You can also wait until 2019-02-15 18:54:52 for the rate limit to reset.

Head to https://github.com/settings/tokens/new?scopes=repo&description=Composer+on+bw-hz-dev-v14+2019-02-15+1755
to retrieve a token. It will be stored in "/data/home/hanguangchao/.config/composer/auth.json" for future use by Composer.
Token (hidden):
Package operations: 1 install, 2 updates, 1 removal
  - Removing bower-asset/jquery.inputmask (3.3.7)
  - Updating yiisoft/yii2-composer (2.0.5 => 2.0.7): Loading from cache
  - Installing bower-asset/inputmask (3.3.11): Downloading (100%)
  - Updating yiisoft/yii2 (2.0.12 => 2.0.16): Loading from cache
Writing lock file
Generating autoload files
  1. Project configuration does not manage bower and npm resources through Composer

If you use Yii2 as an interface application or micro framework, you don't need JS or CSS, or manage the front-end resources by yourself. You can remove the dependency on bower and npm resources when installing and updating.

Modify composer.json

  "require" : {
      "yiisoft/yii2": "2.0.16"
  },
  "replace": {
      "bower-asset/inputmask": ">=3.2.0"
  }

Upgrade on demand

composer update yiisoft/yii2 yiisoft/yii2-composer bower-asset/jquery.inputmask

If there is an error, it is usually a front-end resource dependency problem. Remove it.


 

Topics: Programming JQuery github npm JSON