简体   繁体   中英

Laravel: php artisan serve doesn't start

I've dug through a few of the other answers here and nothing seems to fit the bill. I'm probably going to leave some information out initially so just let me know what else you might need and thanks!

Currently running ubuntu 7, using composer and laravel both of which seem to be installed properly:

When I type 'php artisan serve' and 'php artisan serve --port:8000' into terminal I get this error:

PHP Warning: require(/home/user/Projects/thingy/bootstrap/../vendor/autoload.php): failed to open stream: No such file or directory in /home/user/Projects/thingy/bootstrap/autoload.php on line 17 PHP Fatal error: require(): Failed opening required '/home/user/Projects/thingy/bootstrap/../vendor/autoload.php' (include_path='.:/usr/share/php') in /home/user/Projects/thingy/bootstrap/autoload.php on line 17

When I attempt to run 'php -S localhost:8000 -t public/' just as an attempt I get the following error upon refresh:

PHP 7.0.18-0ubuntu0.17.04.1 Development Server started at Thu Jul 6 09:15:36 2017 Listening on http://localhost:8000 Document root is /home/user/Projects/thingy/public Press Ctrl-C to quit. [Thu Jul 6 09:15:40 2017] PHP Warning: require(/home/user/Projects/thingy/bootstrap/../vendor/autoload.php): failed to open stream: No such file or directory in /home/user/Projects/thingy/bootstrap/autoload.php on line 17 [Thu Jul 6 09:15:40 2017] PHP Fatal error: require(): Failed opening required '/home/user/Projects/thingy/bootstrap/../vendor/autoload.php' (include_path='.:/usr/share/php') in /home/user/Projects/thingy/bootstrap/autoload.php on line 17 [Thu Jul 6 09:15:40 2017] 127.0.0.1:57214 [500]: / - require(): Failed opening required '/home/user/Projects/thingy/bootstrap/../vendor/autoload.php' (include_path='.:/usr/share/php') in /home/user/Projects/thingy/bootstrap/autoload.php on line 17

I checked to see if maybe a server was already running using the 'ps -ef | grep php' command in terminal and I don't see any servers running at all.

I have run 'composer install' and I get the following error:

Cannot create cache directory /home/user/.composer/cache/repo/https---packagist.org/, or directory is not writable. Proceeding without cache Cannot create cache directory /home/user/.composer/cache/files/, or directory is not writable. Proceeding without cache Cannot create cache directory /home/user/.composer/cache/repo/https---packagist.org/, or directory is not writable. Proceeding without cache Loading composer repositories with package information Installing dependencies (including require-dev) from lock file Your requirements could not be resolved to an installable set of packages.

Problem 1 - Installation request for laravel/framework v5.4.28 -> satisfiable by laravel/framework[v5.4.28]. - laravel/framework v5.4.28 requires ext-mbstring * -> the requested PHP extension mbstring is missing from your system.
Problem 2 - Installation request for phpunit/php-code-coverage 4.0.8 -> satisfiable by phpunit/php-code-coverage[4.0.8]. - phpunit/php-code-coverage 4.0.8 requires ext-dom * -> the requested PHP extension dom is missing from your system. Problem 3 - Installation request for phpunit/phpunit 5.7.21 -> satisfiable by phpunit/phpunit[5.7.21]. - phpunit/phpunit 5.7.21 requires ext-dom * -> the requested PHP extension dom is missing from your system. Problem 4 - laravel/framework v5.4.28 requires ext-mbstring * -> the requested PHP extension mbstring is missing from your system. - laravel/tinker v1.0.1 requires illuminate/console ~5.1 -> satisfiable by laravel/framework[v5.4.28]. - Installation request for laravel/tinker v1.0.1 -> satisfiable by laravel/tinker[v1.0.1].

To enable extensions, verify that they are enabled in your .ini files: - /etc/php/7.0/cli/php.ini - /etc/php/7.0/cli/conf.d/10-opcache.ini - /etc/php/7.0/cli/conf.d/10-pdo.ini - /etc/php/7.0/cli/conf.d/20-calendar.ini - /etc/php/7.0/cli/conf.d/20-ctype.ini - /etc/php/7.0/cli/conf.d/20-exif.ini - /etc/php/7.0/cli/conf.d/20-fileinfo.ini - /etc/php/7.0/cli/conf.d/20-ftp.ini - /etc/php/7.0/cli/conf.d/20-gettext.ini - /etc/php/7.0/cli/conf.d/20-iconv.ini - /etc/php/7.0/cli/conf.d/20-json.ini - /etc/php/7.0/cli/conf.d/20-pdo_pgsql.ini - /etc/php/7.0/cli/conf.d/20-pgsql.ini - /etc/php/7.0/cli/conf.d/20-phar.ini - /etc/php/7.0/cli/conf.d/20-posix.ini - /etc/php/7.0/cli/conf.d/20-readline.ini - /etc/php/7.0/cli/conf.d/20-shmop.ini - /etc/php/7.0/cli/conf.d/20-sockets.ini - /etc/php/7.0/cli/conf.d/20-sysvmsg.ini - /etc/php/7.0/cli/conf.d/20-sysvsem.ini - /etc/php/7.0/cli/conf.d/20-sysvshm.ini - /etc/php/7.0/cli/conf.d/20-tokenizer.ini - /etc/php/7.0/cli/conf.d/20-zip.ini You can also run php --ini php --ini inside terminal to see which files are used by PHP in CLI mode.

When running 'composer dump-autoload' I get the following:

Cannot create cache directory /home/user/.composer/cache/repo/https---packagist.org/, or directory is not writable. Proceeding without cache Cannot create cache directory /home/user/.composer/cache/files/, or directory is not writable. Proceeding without cache Cannot create cache directory /home/user/.composer/cache/repo/https---packagist.org/, or directory is not writable. Proceeding without cache Generating optimized autoload files

After following the advice of Nishan Karunarathna and Alex I now get the following error when I run 'php artisan serve':

PHP Fatal error: Uncaught Error: Class 'Illuminate\\Foundation\\Application' not found in /home/joshua/Projects/thingy/bootstrap/app.php:14 Stack trace:

0 /home/joshua/Projects/thingy/artisan(18): require_once()

1 {main} thrown in /home/joshua/Projects/thingy/bootstrap/app.php on line 14

Thanks for any help you give!

I think you should:

1) Install additional php extensions. Run into your terminal something like: $ sudo apt-get install php7.0-opcache php7.0-calendar php7.0-ctype php7.0-gettext ...

2) Then give permissions to cache dir of composer: $ sudo chmod -R u+w /home/joshua/.composer or if this directory is absent your should create its before $ sudo mkdir /home/joshua/.composer

3) Run $ composer install

But I'd like to pay your attention on:

1) Check your home directory on write permissions. If you don't have them, the most part of programs can't work correctly

2) Probably you have needed php extensions but they are not loaded. In this case check your .ini files and enable extensions.

You have sort out the errors when encountered when doing composer install.

Install required PHP extensions

sudo apt-get install php7.0-mbstring

sudo apt-get install php7.0-xml

Then restart your nginx and try to run composer install again.

Ok so I managed to answer my own question (actually a friend answered it for me.)

Apparently after you install laravel and composer it can, on occasion, lose the file path:

I had to open my .bashrc file in my hidden files on the /home/user/ level and add the command 'export PATH=~/.composer/vendor/bin:$PATH'

I think the other users here did contribute to fixing my problem as laravel and composer didn't seem to be installed correctly despite the files being in the proper place.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM