1. 程式人生 > >Centos下安裝compoer, 解決vendor目錄問題

Centos下安裝compoer, 解決vendor目錄問題

laravel部署時使用git拉程式碼的話,vendor目錄部署是沒有提交到git上的,如果沒有該目錄,服務會報錯如下

Warning: require(/opt/soft/pro/bootstrap/../vendor/autoload.php): failed to open stream: No such file or directory in /opt/soft/pro/bootstrap/autoload.php on line 17

Fatal error: require(): Failed opening required '/opt/soft/pro/bootstrap/../vendor/autoload.php' (include_path='.:/usr/share/pear:/usr/share/php') in /opt/soft/pro/bootstrap/autoload.php on line 17
解決辦法:composer install --no-scripts

參考連結:https://stackoverflow.com/questions/26887111/laravel-php-fatal-error-require-failed-opening-required-bootstrap-autolo

 

安裝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');" mv composer.phar /usr/bin/composer