Resolving ‘Class Not Found’ Error in Laravel

January 31st, 2013 - Posted by Steve Marks to PHP, Web Development.

I’ve been building a site recently that uses Laravel and so far, so good. I did run into one small issue however that I wanted to explain as there wasn’t much written about it on the web.

The scenario arose when I was trying to call a model’s method from a controller. Let’s look at a simple example:


public function action_perform_search()
	return Company_user::search();

At an initial glance there doesn’t seem to be anything wrong with this. The ‘Company_user’ model definitely existed so why would this ‘Class Not Found’ error be showing?

The Solution

After a bit of trial and error it turned out that the error was due to my class name containing an underscore. To get around it I simply mapped the model directly in my application/start.php file like so:

	'Base_Controller' => path('app').'controllers/base.php',
	'Company_user' => path('app').'models/company_user.php',
Tags: , ,
This entry was posted on Thursday, January 31st, 2013 at 6:56 am by +Steve Marks and is filed under PHP, Web Development. You can follow any responses to this entry through the RSS 2.0 feed.

Fear not, we won't publish this

Comments (2)
  1. Joe Allen says:

    Thank you very much. You’re right, there is not much on this topic, but I thank you for taking the time to write and post on it. Exactly what I was looking for


  2. Shaun says:

    Hey I also have came across the problem when I moved my laravel project to a linux server. It is case sensitive so it wasn’t picking up my models:

    staffLocation.php and staffDepartment on my windows development server worked fine but when uploaded they could not be found.


    class DepartmentStaff extends Eloquent
    { …

    Changing to DepartmentStaff.php worked for me, didn't think lowercase would of been a problem but evidently it is.