码迷,mamicode.com
首页 > 其他好文 > 详细

Laravel 安装predis 扩展

时间:2016-12-19 11:26:21      阅读:1385      评论:0      收藏:0      [点我收藏+]

标签:pil   serial   span   with   load   auto   http   class   安装教程   

在安装predis扩展之前先安装composer,安装教程在https://getcomposer.org/download/

php -r "copy(‘https://getcomposer.org/installer‘, ‘composer-setup.php‘);"
php -r "if (hash_file(‘SHA384‘, ‘composer-setup.php‘) === ‘c32408bcd017c577ce80605420e5987ce947a5609e8443dd72cd3867cc3a0cf442e5bf4edddbcbe72246a953a6c48e21‘) { echo ‘Installer verified‘; } else { echo ‘Installer corrupt‘; unlink(‘composer-setup.php‘); } echo PHP_EOL;"
php composer-setup.php
php -r "unlink(‘composer-setup.php‘);"

接着把composer设置全局环境变量:

mv composer.phar /bin/composer

把composer镜像地址改为国内的会快很多,教程地址:http://pkg.phpcomposer.com/

composer config -g repo.packagist composer https://packagist.phpcomposer.com

然后开启php-pear,php-devel和php-redis扩展,我是直接用CentOS 的yum包来安装扩展:

yum -y install php70w-devel.x86_64
yum install php70w-pear.noarch
yum -y install php70w-pecl-redis.x86_64 

安装完成后切换到你的网站根目录下,成功后如图所示:

composer require predis/predis
Using version ^1.1 for predis/predis
./composer.json has been updated
> php artisan clear-compiled
Loading composer repositories with package information
Updating dependencies (including require-dev)
  - Installing predis/predis (v1.1.1)
    Downloading: 100%         

predis/predis suggests installing ext-phpiredis (Allows faster serialization and deserialization of the Redis protocol)
Writing lock file
Generating autoload files
> php artisan optimize

 

接着就可以在你的Controller中使用 use Redis 来各种操作了。

Laravel 安装predis 扩展

标签:pil   serial   span   with   load   auto   http   class   安装教程   

原文地址:http://www.cnblogs.com/evai/p/6196536.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!