我在 laravel 上遇到了 redis 的问题。我在 windows 和 linux 上有相同的项目。从作曲家安装“predis/predis”包后,一切都可以在 Windows 上运行。
$ composer require predis/predis
You are running composer with xdebug enabled. This has a major impact on runtime performance. See https://getcomposer.org/xdebug
Using version ^1.0 for predis/predis
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
- Installing predis/predis (dev-master d55826f)
Cloning d55826f35cbce2e1125d91500ccfa00ee1a82a8d
predis/predis suggests installing ext-phpiredis (Allows faster serialization and deserialization of the Redis protocol)
Writing lock file
Generating autoload files
> Illuminate\Foundation\ComposerScripts::postUpdate
> php artisan optimize
Generating optimized class loader
$ php artisan tinker
Psy Shell v0.7.2 (PHP 7.0.6 ÔÇö cli) by Justin Hileman
>>> Redis::connection()
=> Predis\Client {#717}
>>>
但是在debian上我有一个这样的问题:
logic@test:~/www/gps-dev-5.2$ php composer.phar update
Loading composer repositories with package information
Updating dependencies (including require-dev)
- Installing predis/predis (dev-master d55826f)
Loading from cache
predis/predis suggests installing ext-phpiredis (Allows faster serialization and deserialization of the Redis protocol)
Generating autoload files
> Illuminate\Foundation\ComposerScripts::postUpdate
> php artisan optimize
Generating optimized class loader
logic@test:~/www/gps-dev-5.2$ php artisan tinker
Psy Shell v0.7.2 (PHP 5.6.20-0+deb8u1 — cli) by Justin Hileman
>>> Redis::connection()
PHP Fatal error: Call to undefined method Redis::connection() in eval()'d code on line 1
>>>
为了获得类的实例,我需要指定特定的命名空间
>>> Illuminate\Support\Facades\Redis::connection();
=> Predis\Client {#725}
我假设有目录权限,但我不是 100% 确定。
Laravel 5.2,
视窗 PHP 7.0,
Debian PHP 5.6