Search code examples
phplaravelcomposer-phplaravel-artisan

'php artisan serve' won't work. tried multiple solutions


I issued 'composer create-project laravel/laravel first-projec'

after creating a new laravel project I cd'd into the project directory and ran 'php artisan serve'

the console prompted the following error:

Warning: require(C:\xampp\htdocs\first-projec\public/../vendor/autoload.php): Failed to open stream: No such file or directory in C:\xampp\htdocs\first-projec\public\index.php on line 34

Fatal error: Uncaught Error: Failed opening required 'C:\xampp\htdocs\first-projec\public/../vendor/autoload.php' (include_path='C:\xampp\php\PEAR') in C:\xampp\htdocs\first-projec\public\index.php:34 Stack trace: #0 {main} thrown in C:\xampp\htdocs\first-projec\public\index.php on line 34

I've tried a couple of solutions with no resolution:

it has to do with the /vendor/autoload.php file and I couldn't figure it out


Solution

  • I initially downloaded PHP manually through the official website (php.net), extracted the folder, added it to the Program Files directory, and created the required environmental variables.

    I Also installed Composer through the Composer Installer.

    the steps above might have caused some obscure problem that I'm not aware of.

    how I solved the problem:

    • deleted the PHP folder.
    • uninstalled composer.
    • downloaded xampp: so PHP would be installed properly unlike the way I did it.
    • removed the old env variable and added a new one with the new location.
    • installed composer.

    now everything is working properly.