从项目安装composer时出现Php致命错误

时间:2017-06-22 22:27:49

标签: php symfony redis composer-php

这是发生的致命错误消息:

Script Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::clearCache handling the post-install-cmd event terminated with an exception


  [RuntimeException]                                                           
  An error occurred when executing the "'cache:clear --no-warmup'" command:    
  PHP Fatal error:  Uncaught Symfony\Component\Debug\Exception\ContextErrorEx  
  ception: Warning: Declaration of Snc\RedisBundle\Client\Phpredis\Client::ge  
  t() should be compatible with Redis::get($key) in /home/PRIVATE/Prop/ve  
  ndor/snc/redis-bundle/Client/Phpredis/Client.php:1389                        
  Stack trace:                                                                 
  #0 /home/PRIVATE/Prop/vendor/symfony/symfony/src/Symfony/Component/Debu  
  g/DebugClassLoader.php(169): Symfony\Component\Debug\ErrorHandler->handleEr  
  ror(2, 'Declaration of ...', '/home/nienormal...', 1389, Array)              
  #1 /home/PRIVATE/Prop/vendor/symfony/symfony/src/Symfony/Component/Debu  
  g/DebugClassLoader.php(169): require_once()                                  
  #2 [internal function]: Symfony\Component\Debug\DebugClassLoader->loadClass  
  ('Snc\\RedisBundle...')                                                      
  #3 /home/PRIVATE/Prop/app/cache/dev/appDevDebugProjectContainer.php(577  
  0): spl_autoload_call('Snc\\RedisBundle...')                                 
  #4 /home/PRIVATE/Prop/vendor/symfony/symfony/src/Symfony/Component/Depe  
  ndencyInjection/Container.php(314): appDevDebugProjectContainer->getSncRedi  
  s_CacheService()                                                             
  #5 /home/PRIVATE/Prop/app/c in /home/PRIVATE/Prop/vendor/snc/redis-  
  bundle/Client/Phpredis/Client.php on line 1389 

此项目是从git克隆的,从composer install安装数据包后会发生此错误。

我想在Ubuntu平台上运行项目,但我在这个主题中完全是绿色的。

抱歉我的英语不好,但也许有人会用这种黑魔法来帮助我。

3 个答案:

答案 0 :(得分:1)

升级到php-redis 3.1.4RC后出现同样的错误。它看起来像BC breaking feature was introduced

对于ondrej ubuntu存储库

cd /tmp
wget https://launchpad.net/~ondrej/+archive/ubuntu/php/+build/12376478/+files/php-redis_3.1.2-1+deb.sury.org~trusty+1_amd64.deb
sudo dpkg -i php-redis_3.1.2-1+deb.sury.org~trusty+1_amd64.deb

答案 1 :(得分:0)

您遇到的错误似乎与作曲家无关,而是使用Symfony应用中的RedisBundle。

看到此消息: Uncaught Symfony\Component\Debug\Exception\ContextErrorException: Warning: Declaration of Snc\RedisBundle\Client\Phpredis\Client::get() should be compatible with Redis::get($key) in /home/PRIVATE/Prop/vendor/snc/redis-bundle/Client/Phpredis/Client.php:1389

显然,您有一个Client课程:Snc\RedisBundle\Client\Phpredis\Client.php从Redis继承/home/PRIVATE/Prop/vendor/snc/redis-bundle/Client/Phpredis/Client.php。 由于它的继承,两种方法都应该具有相同的签名。

因此,请更改您的方法Client::get() - > Client::get($key),即使您没有使用$key参数。 它应该工作正常。

答案 2 :(得分:0)

您可以从source安装phpredis 3.1.2。只需克隆一个repo,切换到标签3.1.2并运行:

phpize
./configure
make && make install

然后在扩展程序的ini文件中更新redis.so的路径。重新加载PHP