Home >Backend Development >PHP Tutorial >Example code for installing redis extension in yii2.0 framework
We have shared many examples of redis extensions with you. This article will share with you the installation of redis extensions in the yii2.0 framework, hoping it will help you.
1. Install through composer, go to the project root directory and run cmd (recommended)
php composer.phar require --prefer-dist yiisoft/yii2-redis
Or add
"yiisoft/yii2-redis": "~2.0.0" to the composer.json file of the corresponding project,
Then run composer update
2. Manual installation
Click to download : yii2.0-redis extension
Put the downloaded extension file under vendor/yiisoft/ and name it yii2-redis
Modify extensions.php under vendor/yiisoft/ and add redis extension
'yiisoft/yii2-redis' => array ( 'name' => 'yiisoft/yii2-redis', 'version' => '2.2.0.0', 'alias' => array ( '@yii/redis' => $vendorDir . '/yiisoft/yii2-redis', ), ),
Instructions:
Use composer require - -prefer-dist yiisoft/yii2-redis
This command first finds the version of the redis extension that can be used. The mandatory requirement is dist Archive.
Modify the local composer.json file.
Download the dependent redis extension and install it.
Write the lock file and generate the autoload file.
Related recommendations:
PHP installation redis extension example under Windows
How to download it to win PHP installed Redis extension
PHP Redis extension from installation to use
The above is the detailed content of Example code for installing redis extension in yii2.0 framework. For more information, please follow other related articles on the PHP Chinese website!