Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Uncaught exception 'ReflectionException' with message 'Class config does not exist' #192

Closed
ngohungphuc opened this issue Feb 10, 2016 · 28 comments

Comments

@ngohungphuc
Copy link

ngohungphuc commented Feb 10, 2016

I have an issue like this i'm using laravel 5.How can i fix it.Thanks for help

download

@OliverGrimsley
Copy link

I have the same issue, cannot load service, class "config" does not exist - using laravel/framework (v5.2.15):

vagrant@engltr:~/engltr$ php artisan vendor:publish
PHP Fatal error: Uncaught ReflectionException: Class config does not exist in /home/vagrant/engltr/vendor/laravel/framework/src/Illuminate/Container/Container.php:738
Stack trace:
#0 /home/vagrant/engltr/vendor/laravel/framework/src/Illuminate/Container/Container.php(738): ReflectionClass->__construct('config')
#1 /home/vagrant/engltr/vendor/laravel/framework/src/Illuminate/Container/Container.php(633): Illuminate\Container\Container->build('config', Array)
#2 /home/vagrant/engltr/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(674): Illuminate\Container\Container->make('config', Array)
#3 /home/vagrant/engltr/vendor/laravel/framework/src/Illuminate/Container/Container.php(1178): Illuminate\Foundation\Application->make('config')
#4 /home/vagrant/engltr/vendor/laravel/framework/src/Illuminate/Support/ServiceProvider.php(65): Illuminate\Container\Container->offsetGet('config')
#5 /home/vagrant/engltr/vendor/barryvdh/laravel-dompdf/src/ServiceProvider.php(26): Illuminate\Support\ServiceProvider->mergeConfigFro in /home/vagrant/engltr/vendor/laravel/framework/src/Illuminate/Container/Container.php on line 738

Fatal error: Uncaught ReflectionException: Class config does not exist in /home/vagrant/engltr/vendor/laravel/framework/src/Illuminate/Container/Container.php:738
Stack trace:
#0 /home/vagrant/engltr/vendor/laravel/framework/src/Illuminate/Container/Container.php(738): ReflectionClass->__construct('config')
#1 /home/vagrant/engltr/vendor/laravel/framework/src/Illuminate/Container/Container.php(633): Illuminate\Container\Container->build('config', Array)
#2 /home/vagrant/engltr/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(674): Illuminate\Container\Container->make('config', Array)
#3 /home/vagrant/engltr/vendor/laravel/framework/src/Illuminate/Container/Container.php(1178): Illuminate\Foundation\Application->make('config')
#4 /home/vagrant/engltr/vendor/laravel/framework/src/Illuminate/Support/ServiceProvider.php(65): Illuminate\Container\Container->offsetGet('config')
#5 /home/vagrant/engltr/vendor/barryvdh/laravel-dompdf/src/ServiceProvider.php(26): Illuminate\Support\ServiceProvider->mergeConfigFro in /home/vagrant/engltr/vendor/laravel/framework/src/Illuminate/Container/Container.php on line 738

@danirect
Copy link

danirect commented Mar 1, 2016

i also ever have same issue, but after i try to remove this code :
$app->register(\Barryvdh\DomPDF\ServiceProvider::class);
and
$app->configure('dompdf');
from bootstrap/app.php the problem solved. And don't forget to add
use PDF
in your controller... hope this will help you

@Rahulsmg
Copy link

Hi,
I also got the same error while creating an controller on laravel project say,
"vagrant@homestead:~/$ php artisan make:controller " and while running the "vagrant@homestead:~/$php artisan vendor:publish "
on terminal working with the laravel project.

The error can be solved!!!
go to /code/laravelproject/config/app.php and edit with
just including provider within ' ' for specifing respective provider name with in the array

Thanks..

@ghost
Copy link

ghost commented Aug 10, 2016

I'm having this same problem with bootstrap/app.php
$app->register(\Barryvdh\DomPDF\ServiceProvider::class); $app->configure('dompdf');

@peterw35
Copy link

Do not include
$app->register(\Barryvdh\DomPDF\ServiceProvider::class); and
$app->configure('dompdf');
in bootstrap/app.php if you are installing for Laravel. They are not part of the install requirement. They are for Lumen

@jatasya
Copy link

jatasya commented Nov 7, 2016

run

 >composer dump-autoload

Or
>composer dump-autoload -o

This solved the issue for me

@Kleinast
Copy link

Kleinast commented Jan 5, 2017

Thanx @peterw35 , I had the same issue beacause I put:
if (env('APP_DEBUG')) { $app->register(Barryvdh\Debugbar\LumenServiceProvider::class); }
In my bootstrap/app.php file.
Can you just tell me where to put this code now ?

Thx

@peterw35
Copy link

@Kleinast you should've open the issue in Barryvdh's Debugbar project, not here.

but the principle is the same. if you are using laravel, do NOT follow any Lumen instructions.
Lumen is NOT laravel. (to be precise, it's a cut down version. It's got minimal packages included for performance)

@shawindershingora
Copy link

in my case it was because i havent given 777 permission to bootstrap/cache/services.php file
after giving permission my project was working fine
hope it helps you :)

@ryscript
Copy link

For me, if you change or update APP_NAME in your .env file with spaces like My Awesome, make sure that you enclose it with " (quote).

@marcoapferegrino
Copy link

@ryscript really weird error I have not read this I've never found this mistake Thanks

@hsali
Copy link

hsali commented Jul 14, 2017

same error has also happened if you don't have conf/datatables.php. try installing latest or above 7.x

composer require yajra/laravel-datatables-oracle

add these lines in config/app.php

 Yajra\Datatables\DatatablesServiceProvider::class,

 Datatables' => Yajra\Datatables\Facades\Datatables::class,

 php artisian config:cache

if you don't have file config/datables.conf. Try to paste these file there.
https://gist.github.com/hsali/1cab0d6c81020bf7bce043b65f94373a

@iktarun
Copy link

iktarun commented Jul 27, 2017

I was facing the same issue.

"Uncaught ReflectionException: Class config does not exist"

I have figured out this, here is the solution:
There may be some error in your environment file It could be any extra character, which is causing error.
In my case it was space. I have changes space character to nbsp In your it can be any other character;

To find the error, Run this command

php artisan cache:clear

Output is like this:

[Dotenv\Exception\InvalidFileException]
Dotenv values containing spaces must be surrounded by quotes.

I have changes the below line(changes space to nbsp)
NOTE:Please write nbsp to "amp%nbsp;" change amp% to & as character(As this page is not rendering it correctly)
MAIL_FROM_NAME=Tarun Kumar
To
MAIL_FROM_NAME=Tarunamp%nbsp;Kumar

@PortionLK
Copy link

I got this same issue, but not related to phpunit.
The issue was I added values containing spaces to my .env file.
If you have values contains spaces in your .env file, surround them with quotes and then it'll be fixed.

if you run php artisan clear-compiled while having this issue, it will tell the solution ;)

@helloakn
Copy link

check your apache user and file system user first.
then run the following command for ur file system permission.



sudo chmod 755 storage -R

sudo chmod 755 vendor -R

sudo chmod 755 bootstrap -R




After you finished the change the file permission.

make sure for your cache. if possible, clean your chache with the following command .



php artisan config:cache

php artisan cache:clear

php artisan config:clear



it works for me.

@Mwalima
Copy link

Mwalima commented Dec 13, 2017

in my case there was a error in the .env file

@gugglegum
Copy link

I had an error in .env file too. In my case an error was due to space character in value without quotes. Like:

MY_ENV_OPTION=John Smith

You need to add quotes like so:

MY_ENV_OPTION="John Smith"

And error will go away.

@MarkL4YG
Copy link

@gugglegum Thanks! That was actually what made a setup throw the exception for me too.
Weird unusable error messages...

@ashish135
Copy link

I'm also having the same error in .env file with APP_NAME.

@MWalid
Copy link

MWalid commented Mar 12, 2018

@ryscript you are a lifesaver!

@spmsupun
Copy link

Had same problem and i've deleted bootstrap/cache/config.php and ran php artisan clear-compiled , now it's working fine

@mikebronner
Copy link

If all the above failed for you, delete all files in project/bootstrap/cache/ and run composer du -o afterwards. That fixed things in my case.

@Jay1991
Copy link

Jay1991 commented Jun 22, 2018

I encounter the same issue after changing APP_NAME in .env file, silly me!

@sohaieb
Copy link

sohaieb commented Aug 19, 2018

I had also the same problem and I follow all answers in Github and Stackoverflow but no thing was helped.
But when I saw @detal92 's comment, I opened bootstrap/app.php and see what's modules are registered in it !
so I found that Debug Module is registred in app.php,
so I disabled Debug in .env file like this :

APP_DEBUG=false

then I run this command :
> php artisan config:cache

and finally :

APP_DEBUG=true


and now all works fine 😄

@luc0
Copy link

luc0 commented Dec 10, 2018

Had same problem and i've deleted bootstrap/cache/config.php and ran php artisan clear-compiled , now it's working fine

This works for me!

@jschlies
Copy link

Good Grief!!!! How long is is this issue going to go on? Whay form of begging/bribery/weeping will get Laravel to fix this!!!!!!!!

@bizsimon
Copy link

bizsimon commented Mar 9, 2019

I got this same issue, but not related to phpunit.
The issue was I added values containing spaces to my .env file.
If you have values contains spaces in your .env file, surround them with quotes and then it'll be fixed.

if you run php artisan clear-compiled while having this issue, it will tell the solution ;)

Same here. Having a space in one of the config would do it
test=abc abc

@modavidc
Copy link

modavidc commented Dec 8, 2019

i also ever have same issue, but after i try to remove this code :
$app->register(\Barryvdh\DomPDF\ServiceProvider::class);
and
$app->configure('dompdf');
from bootstrap/app.php the problem solved. And don't forget to add
use PDF
in your controller... hope this will help you

Thanks, It worked in my case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests