apt安装composer导致的一些问题。

2019独角兽企业重金招聘Python工程师标准>>> hot3.png

问题一

root@iZbp1d:composer require predis/predis
Using version ^1.1 for predis/predis
./composer.json has been updated
PHP Fatal error:  strict_types declaration must be the very first statement in the script in /usr/share/php/Composer/Plugin/PluginManager.php(178) : eval()'d code on line 3

Fatal error: strict_types declaration must be the very first statement in the script in /usr/share/php/Composer/Plugin/PluginManager.php(178) : eval()'d code on line 3

这种情况的话更新就能解决。

composer self-update

问题二

  [InvalidArgumentException]             
  Command "self-update" is not defined.

出现这种情况的,一般都是apt安装惹的祸,那么我们先卸载apt安装的composer

sudo apt-get remove composer

然后自己安装:

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

然后添加到变量中去:

sudo mv composer.phar /usr/local/bin/composer

这样就能愉快的使用composer了。

转载于:https://my.oschina.net/jishuge/blog/2984312

你可能感兴趣的:(php,python,json)