elo's avatar
Level 3

Class 'Carbon\carbon' not found in web.php

Hi, I'm working with Laravel 5.4 and my app works perfectly on my local system. As part of my development, I'm testing how to deploy laravel on shared hosting (though i have read that VPS is recommended). I have followed the steps here

[http://novate.co.uk/deploy-laravel-5-on-shared-hosting-from-heart-internet/]

and looks like I'm almost there but I get the error Class 'Carbon\carbon' not found in web.php

This is the line throwing up the error

<?php
use Carbon\carbon;

Route::get('/', function () {
    
    $today = Carbon::now()->toDateString();

    //dd($today);

    $prices = App\Price::with('product')->whereDate('date', $today)->get();

    return view('welcome', compact('prices'));
});

What am I doing wrong?

0 likes
4 replies
Robert-Jan's avatar

It's Carbon\Carbon. The second Carbon is also a capital first letter.

2 likes
elo's avatar
elo
OP
Best Answer
Level 3

@Robert-Jan Thanks, I will make that correction. However I got it to work by renaming the config.php file in bootstrap/cache/ path. Based on what I read from another thread, it looks like the route path on my local server were cached. I would love to know it this is the best way to fix this issue though.

Robert-Jan's avatar

@elo In that case i think it has to do with the permissions of that folder. The bootstrap/cache has to be writable in order to work correctly. Or if that doesn't work on that shared hosting running it without is not a huge deal except when you have a lot of routes or a lot of traffic to the website.

Please or to participate in this conversation.