Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Laravel 4 Model class not found

I just created a simple app in Laravel 4 and when I create a model, I get an exception that it's not found.

// /app/models/Worker.php:
<?php

class Worker extends Eloquent {}

And then in the Controller

var_dump(Worker::find(1));

This gives me Error: Class 'Worker' not found. What am I doing wrong? This used to work in Laravel 3 and also watching the screencasts it seems like this should work.

like image 317
duality_ Avatar asked Jan 11 '13 18:01

duality_


2 Answers

Anytime you create a new class file in L4 run this command.

php composer dump-autoload
like image 132
anthony.c Avatar answered Oct 19 '22 02:10

anthony.c


I think there are two commands to get the autoload started:

$ composer dump-autoload  

and

$ php artisan dump-autoload

Seems composer dump-autoload is to let composer create autoloads as defined in the composer.json files. And php artisan dump-autoload glues all the composer dump-autoloads ( also from vendors and workbenches ) together.

like image 5
Joeri Avatar answered Oct 19 '22 02:10

Joeri