Search code examples
phplaravelshared-hosting

Laravel: Class not found Exception


In my Laravel project, if have a file app/lib/Formatter.php, with an class Formatter.
From a Controller i am importing this php file using use App\Lib\Formatter; In my local development enviroment, I can access methods from the Formatter in my Controller. But when i deploy the laravel project to a share hosting, i can't access Formatter. Laravel returns this error message:

"Class 'App\Lib\Formatter' not found"

After it works localy, i don't have any idea, why it shouldn't work on shared hosting.


Solution

  • Linux is casesensitive. You should rename your folder from lib to Lib.

    If your folder tree looks like App\lib\Formatter.php rename your library to App\Lib\Formatter.php.