bhupesh shakya
bhupesh shakya

Reputation: 98

Fatal error while running php artisan serve>

I am new to Laravel. I don't why this isn't working.

user@user-MS-7529:~/blog$ php artisan key:generate --ansi
PHP Warning:  require(/home/user/blog/vendor/autoload.php): Failed to open stream: No such file or directory in /home/user/blog/artisan on line 18
PHP Fatal error:  Uncaught Error: Failed opening required '/home/user/blog/vendor/autoload.php' (include_path='.:/usr/share/php') in /home/user/blog/artisan:18
Stack trace:
#0 {main}
  thrown in /home/user/blog/artisan on line 18

Upvotes: 0

Views: 7815

Answers (3)

bhupesh shakya
bhupesh shakya

Reputation: 98

Thanks everyone for your precious time the error has now been fixed This caused error because during the time making laravel project it has caused some error in my case php-mbstring and php-xml was not availabe or installed on my system somehow. you can simply fixed it by

sudo apt-get update

sudo apt-get install php-mbstring

or if got the older version

sudo apt-get install php7.2-mbstring

sudo apt install php-xml

And boom your error got fixed!!!Hope this could be useful in future

Upvotes: 1

sdebarun
sdebarun

Reputation: 99

  1. Check you have installed composer properly. use composer in terminal or CMD in your OS. If composer is properly installed you will see a composer ascii art in terminal or in cmd.
  2. Assuming composer is installed properly then check with the version of the laravel you have installed. You can do this by opening the composer.json file and check for "laravel/framework". Alternatively you can run this command in your project directory in a terminal php artisan --version.
  3. Now check your PHP version. You can use to check what version of PHP you are running on. If you are using latest laravel framework then you need at least PHP 7.3.0.

Also if you have pulled the codebase from git then you need to run composer update in your project directory to get all the packages installed in vendor folder.

Upvotes: 0

Midhun Raj
Midhun Raj

Reputation: 987

Install Composer ..

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

Make sure you have run:

composer install

Now it seems packages are not installed. If they are, try running:

composer dump-autoload

Then run

composer global update

Try to to give permission for that vendor folder

sudo chmod -R 777 vendor

update your composer also

composer update

Upvotes: 0

Related Questions