欢迎各位兄弟 发布技术文章

这里的技术是共享的

You are here

安装 Laravel 遇到问题?你需要更新 composer.json 文件

shiping1 的头像

在使用最新版 Composer 安装 Laravel 的时候,你可能会遇到下面的问题而安装失败:


  1. $ php composer.phar create-project --prefer-dist laravel/laravel blog
  2. Installing laravel/laravel (v5.2.15)
  3. - Installing laravel/laravel (v5.2.15)
  4. Loading from cache
  5.  
  6. Created project in blog
  7. > php -r "copy('.env.example', '.env');"
  8. > php artisan clear-compiled
  9. PHP Warning: require(/home/vagrant/laraveltest/blog/bootstrap/../vendor/autoload.php): failed to open stream: No such file or directory in /home/vagrant/laraveltest/blog/bootstrap/autoload.php on line 17
  10. PHP Fatal error: require(): Failed opening required '/home/vagrant/laraveltest/blog/bootstrap/../vendor/autoload.php' (include_path='.:/usr/share/pear:/usr/share/php') in /home/vagrant/laraveltest/blog/bootstrap/autoload.php on line 17
  11. Script php artisan clear-compiled handling the pre-update-cmd event returned with an error
  12.  
  13.  
  14. [RuntimeException]
  15. Error Output: PHP Warning: require(/home/vagrant/laraveltest/blog/bootstrap/../vendor/autoload.php): failed to open stream: No such file or directory in /home/vagrant/laraveltest/bl
  16. og/bootstrap/autoload.php on line 17
  17. PHP Fatal error: require(): Failed opening required '/home/vagrant/laraveltest/blog/bootstrap/../vendor/autoload.php' (include_path='.:/usr/share/pear:/usr/share/php') in /home/vagr
  18. ant/laraveltest/blog/bootstrap/autoload.php on line 17
  19.  
  20.  
  21. create-project [-s|--stability STABILITY] [--prefer-source] [--prefer-dist] [--repository REPOSITORY] [--repository-url REPOSITORY-URL] [--dev] [--no-dev] [--no-plugins] [--no-custom-installers] [--no-scripts] [--no-progress] [--keep-vcs] [--no-install] [--ignore-platform-reqs] [--] [<package>] [<directory>] [<version>]

这是由于 Composer 最近更新了 pre-update-command 的工作方式,而这会使得 Laravel 安装失败。

@Jordi Boggiano 给出的原因如下:

这是由于缺少 composer.lock 文件,因此最初的 install 命令被 update 操作替代,因为它会触发 pre-update-cmd,而在这之前是触发的 pre-install-cmd。

幸运的是,修复这个问题非常简单,只需要把 php artisan clear-compiled 移动到 post-update-command 即可:

laravel-composer-change

这里是完整的 ChangeLog

来自 http://9iphp.com/web/laravel/laravel-install-fail-update-composer.html

普通分类: