3

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.

Charbel Sarkis
  • 81
  • 1
  • 2
  • 9

6 Answers6

4
  1. First Install Composer: composer install.
  2. Then run a command in CMD prompt: composer dump-autoload.
NARGIS PARWEEN
  • 1,489
  • 3
  • 16
  • 26
  • i have composer. that's how i installed laravel **composer global require laravel/installer** – Charbel Sarkis Jun 01 '18 at 13:31
  • @Charbel Well that command won't install composer as of course you didn't expect to be able to install composer via composer, did you? That will install all the "dependencies" for your project that are missing for some reason, using composer and the `composer.json` file in root path of your project. So just do this: In the root path of your project, run `composer install`. Remember you have to run this in the path that the `composer.json` file of your project is located which in this case, will always be the root dir of your laravel project. It will download and install all the dependencies. Y – arm Jun 03 '19 at 04:49
  • @arm That wasn't the problem. Apparently laravel **requires** php 7.2 from that point in time. And i had a much older version. – Charbel Sarkis Jun 28 '19 at 21:35
2

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

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

Nico Bistolfi
  • 96
  • 1
  • 8
  • `Generating optimized autoload files Class Illuminate\Foundation\ComposerScripts is not autoloadable, can not call post-autoload-dump script > @php artisan package:discover Fatal error: Class 'Illuminate\Foundation\Application' not found in C:\Projects\laravel-projects\blog\bootstrap\app.php on line 14 Script @php artisan package:discover handling the post-autoload-dump event returned with error code 255` – Charbel Sarkis May 31 '18 at 20:36
  • this is the error that i got from `composer dump-autoload` – Charbel Sarkis May 31 '18 at 20:36
  • `php artisan serve` after running this command `Fatal error: Class 'Illuminate\Foundation\Application' not found in C:\Projects\laravel-projects\blog\bootstrap\app.php on line 14` – Charbel Sarkis May 31 '18 at 20:37
  • Check this post then -> https://stackoverflow.com/questions/29764368/fatal-error-class-illuminate-foundation-application-not-found – Nico Bistolfi Jun 07 '18 at 18:38
1

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.

Rick Wang
  • 11
  • 2
0

You could try install via Composer Create-Project:

composer create-project --prefer-dist laravel/laravel blog
  • This doesn't change anything the file still points to an empty directory. Had to change the url to the correct one and got a new error – Charbel Sarkis May 31 '18 at 22:34
0

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

Charbel Sarkis
  • 81
  • 1
  • 2
  • 9
-1

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
chohan
  • 58
  • 4