barryvdh / laravel-dompdf

A DOMPDF Wrapper for Laravel
MIT License
6.76k stars 976 forks source link

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

Closed ngohungphuc closed 6 years ago

ngohungphuc commented 8 years ago

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

download

OliverGrimsley commented 8 years ago

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 commented 8 years ago

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 commented 8 years ago

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 commented 8 years ago

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

peterw35 commented 8 years ago

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 commented 8 years ago

run

 >composer dump-autoload

Or

composer dump-autoload -o

This solved the issue for me

Kleinast commented 7 years ago

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 commented 7 years ago

@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 commented 7 years ago

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 commented 7 years ago

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 commented 7 years ago

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

hsali commented 7 years ago

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 commented 7 years ago

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 commented 7 years ago

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 commented 7 years ago

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 commented 6 years ago

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

gugglegum commented 6 years ago

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 commented 6 years ago

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

ashish135 commented 6 years ago

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

MWalid commented 6 years ago

@ryscript you are a lifesaver!

spmsupun commented 6 years ago

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

mikebronner commented 6 years ago

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 commented 6 years ago

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

sohaieb commented 6 years ago

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 commented 5 years ago

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 commented 5 years ago

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 commented 5 years ago

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 commented 4 years ago

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.