Search code examples
cakephpcakephp-3.0cakephp-3.x

CakePHP3 - require autoload failed to open stream, no such file or directory


After deploying my CakePHP3 project to Ubuntu 14.04 server when I open project in browser I get this error:

Warning: require(/var/www/html/xyz-web/vendor/autoload.php): failed to open stream: No such file or directory in /var/www/html/xyz-web/config/bootstrap.php on line 38

Fatal error: require(): Failed opening required '/var/www/html/xyz-web/vendor/autoload.php' (include_path='.:/usr/share/php:/usr/share/pear') in /var/www/html/xyz-web/config/bootstrap.php on line 38

And if I run bin/cake server inside that directory (on the server) I get next output:

Warning: require(/var/www/html/xyz-web/vendor/autoload.php): failed to open stream: No such file or directory in /var/www/html/xyz-web/config/bootstrap.php on line 38 PHP Fatal error: require(): Failed opening required '/var/www/html/xyz-web/vendor/autoload.php' (include_path='.:/usr/share/php:/usr/share/pear') in /var/www/html/xyz-web/config/bootstrap.php on line 38

Fatal error: require(): Failed opening required '/var/www/html/xyz-web/vendor/autoload.php' (include_path='.:/usr/share/php:/usr/share/pear') in /var/www/html/xyz-web/config/bootstrap.php on line 38

How do I solve this?


Solution

  • I solved this issue by installing composer on the server and running it inside a project.

    sudo apt-get update && sudo apt-get install curl php5-cli git && curl -sS https://getcomposer.org/installer | sudo php -- --install-dir=/usr/local/bin --filename=composer
    

    and then cd to cake project (cd /var/www/html/{project_name}) and run composer install to install required packages.