Class 'App - HTTP - Controllers - Carbon' Not Found
Class 'App - HTTP - Controllers - Carbon' Not Found
18601 15 LARAVEL
I added the "use" statements, but for some reason Carbon cannot be found. I also tried use
\Carbon\Carbon; instead, which didn't work either.
You're in the Controller namespace, so you're referencing carbon in a Controller without a use
1 Reply
JackJones
Posted 5 years ago
The fact your in the Controller namespace says you've done something wrong
1 Reply
Dry7
Posted 5 years ago
Copy Code
compose dump
https://laracasts.com/discuss/channels/laravel/class-apphttpcontrollerscarbon-not-found 2/7
2/10/22, 14:25 Class 'App\Http\Controllers\Carbon' not found
1 Reply
ctwx
Posted 5 years ago
Reply
Cronix
Top 10 Leaderboard Posted 5 years ago
2 Reply
JackJones
Posted 5 years ago
@ctwx It's looking in the Controller namespace, so where did you put the use in the file?
1 Reply
ctwx
Posted 5 years ago
(1/1) FatalThrowableError
Class 'App\Http\Controllers\Carbon' not found
Reply
ctwx
Posted 5 years ago
That's why I tried it with a backslash before Carbon. That should right, shouldn't it?
Reply
https://laracasts.com/discuss/channels/laravel/class-apphttpcontrollerscarbon-not-found 3/7
2/10/22, 14:25 Class 'App\Http\Controllers\Carbon' not found
You're in the Controller namespace, so you're referencing carbon in a Controller without a use
1 Reply
ctwx
Posted 5 years ago
Ohhh damn!!
Reply
Snapey
Top 10 Leaderboard Posted 5 years ago
This App\Http\Controllers in the errors is telling me this is nothing to do with the AppServiceprovider.
Reply
Cronix
Top 10 Leaderboard Posted 5 years ago
I think you're a bit confused. You're not even using carbon in the AppServiceProvider. The problem is
somewhere else in your code that you are using Carbon. use Carbon\Carbon; is correct, btw. I use it
all over the place.
1 Reply
Snapey
Top 10 Leaderboard Posted 5 years ago
@ Nickels
https://laracasts.com/discuss/channels/laravel/class-apphttpcontrollerscarbon-not-found 4/7
2/10/22, 14:25 Class 'App\Http\Controllers\Carbon' not found
In laravel 5.5 laravel got pulled in as a dependency of the framework and should be use with
use Illuminate\Support\Carbon;
surely not... that would be a major breaking change (not mentioned in release notes)
1 Reply
ctwx
Posted 5 years ago
The error was not coming from the AppServiceProvider, it was in my Controller.
First, there was a missing use in the AppServiceProvider, then the next error was in my controller. But
I didn't realize it and thought it was there... :-/ Sorry...
Reply
JackJones
Posted 5 years ago
https://github.com/laravel/framework/blob/5.5/src/Illuminate/Support/Carbon.php
Reply
Snapey
Top 10 Leaderboard Posted 5 years ago
2 Reply
https://laracasts.com/discuss/channels/laravel/class-apphttpcontrollerscarbon-not-found 5/7