2
votes

I'm working on an e-commerce project on Laravel 5.8, but since I accidently ran "laravel new" command on the project's folder I get this error when I'm trying to launch the project on a local server:

Fatal error: Uncaught ReflectionException: Class config does not exist in C:\wamp64\www\e-commerce\vendor\laravel\framework\src\Illuminate\Container\Container.php:788 Stack trace: 0 C:\wamp64\www\e-commerce\vendor\laravel\framework\src\Illuminate\Container\Container.php(788): ReflectionClass->__construct('config') 1 C:\wamp64\www\e-commerce\vendor\laravel\framework\src\Illuminate\Container\Container.php(667): Illuminate\Container\Container->build('config') 2 C:\wamp64\www\e-commerce\vendor\laravel\framework\src\Illuminate\Container\Container.php(615): Illuminate\Container\Container->resolve('config', Array) 3 C:\wamp64\www\e-commerce\vendor\laravel\framework\src\Illuminate\Foundation\Application.php(767): Illuminate\Container\Container->make('config', Array) 4 C:\wamp64\www\e-commerce\vendor\laravel\framework\src\Illuminate\Container\Container.php(1227): Illuminate\Foundation\Application->make('config') 5 C:\wamp64\www\e-commerce\vendor\laravel\framework\src\Illuminate\Log\LogManager.php(417): Illuminate\Container\C in C:\wamp64\www\e-commerce\vendor\laravel\framework\src\Illuminate\Container\Container.php on line 788"

The error on line 788 refers to that portion of code:

$reflector = new ReflectionClass($concrete)

This happened after I cloned my repo from Github. Now for every project that I try to run on a local server I get this error.

I tried "composer install", "composer update", "composer dump-autoload" but they all give the same error with this line at the end: "Script @php artisan package:discover --ansi handling the post-autoload-dump event returned with error code 255".

I checked the .env file to see if there was a namespace issue too, but there's none of it.

Thank you in advance for your help.

5
Was the repo up to date before you naffed your project folder?RiggsFolly
Modify your composer.json to remove any artisan script call out of the scripts section. Then try again.aynber
composer update --no-scripts and then try composer updateDilip Hirapara
RiggsFolly actually no, it wasn't.IbraProjects

5 Answers

10
votes

Try to remove de files in:

cd bootstrap/cache/
rm -rf *.php

In this directory are the file that initializes the structure, cache directory that contains structure-generated files for performance optimization, such as files and route cache services.

1
votes

I tried @gulCunha 's answer and it worked.

After that, you have to run composer update in order to create a new composer.lock and php artisan config:cache after that and you should be good to go.

1
votes

Did you change the .env file,mistakenly I have added a "APP_NAME=aaa aa " with spaces, then checked every where, after that APP_NAME= changed without spaces, now working charm.

0
votes

Make sure your .env file is the exact same as in your local environment. Make sure that the values on your .env file don't have spaces. Those that have spaces should be wrapped in quotes

0
votes

You may check the following items

  1. Check whether your APP_NAME has space. If space is there, use it in quotes.
  2. Delete everything from bootstrap/cache/ folder.
  3. run composer dump-autoload

Hope it will work