Home  >  Article  >  Backend Development  >  Example code for installing redis extension in yii2.0 framework

Example code for installing redis extension in yii2.0 framework

小云云
小云云Original
2018-03-07 09:20:502056browse

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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn