php artisan服务找不到autoload.php

SOLUTION: laravel new project-name was actually giving me an error that i overlooked. I had the wrong version of php. It requires phpv7.1.3 or higher. If you don't have it it doesn't work.

Ran into one other problem:

  • i had a system environment variable that is pointing to an old version of php
  • Also laravel requires openssl extension and mbstring to turned on. UNCOMMENTED from php.ini

FOR NEWCOMERS: if you have just downloaded php and unzipped the file. It contains a file called

install.txt

that you HAVE to read. It explains everything.

I ran laravel new blog from their getting started page. When I tried to run php artisan serve, I got the following error:

Warning: require(C:\Projects\laravel-projects\blog/vendor/autoload.php): failed to open stream: No such file or directory in C:\Projects\laravel-projects\blog\artisan on line 18

The artisan file is pointing to

require __DIR__.'/vendor/autoload.php';

this directory does not exist. Even if I point it to the correct directory, it still wouldn't work because I don't have read permissions for that folder (so it gets denied).

What's going on, and how can I fix this?

EDIT: changed the url from the mentioned above to:

C:\Users\sarkis\AppData\Roaming\Composer\vendor\autoload.php

This worked perfectly for some reason. And NOW. A NEW ERROR HAS APPEARED.

Fatal error: Uncaught Error: Class 'Illuminate\Foundation\Application' not found in C:\Projects\laravel-projects\blog\bootstrap\app.php:14 Stack trace:#0 C:\Projects\laravel-projects\blog\artisan(21): require_once() #1 {main} thrown in C:\Projects\laravel-projects\blog\bootstrap\app.php on line 14

found that i don't have the proper version of php required.

Try running composer dump-autoload , after that run a composer install

If that doesn't work, try the composer update --no-scripts

Check all your permissions to following folders and give 0777 permissions

storage 0777
vendor 0777
bootstrap/cache 0777

And then run again

php artisan serve

You could try install via Composer Create-Project:

composer create-project --prefer-dist laravel/laravel blog
  1. First Install Composer: composer install.
  2. Then run a command in CMD prompt: composer dump-autoload.

When running laravel new project_name. It outputted the text php 7.1.3 or higher needs to be installed. Current version 5.6 does not match requirements. And it aborts without plainly giving you an error. Be sure to download php version 7.1.3 or higher. Also check if you have environment variables for earlier versions of php and delete those.

note: be sure to read install.txt from the php download

I'm new to Laravel, and I got the same confusion with the command:

laravel new blog

There was no vendor folder.

But after I tried:

composer create-project --prefer-dist laravel/laravel blog

I found the vendor folder came up.

Don't know why either.