Question: When starting to work with models I got the following error 

> 
> Class Post not found`. 
> 
> 
> 

All I did:  

- Created a Model with the command `php artisan make:model`  

- Tried to get all entries from table `posts` with `echo Post::all()` 

I used the following code:

**router.php**

```
Route::get('/posts', function(){
    $results = Post::all();
    return $results;
});

```

**Post.php** 

```
<?php 
namespace App;

use Illuminate\Database\Eloquent\Model;

class Post extends Model {
    protected $table = 'posts';    
}

```

What I tried  

- Renaming Class  

- Dump-autoload ([Laravel 4 Model class not found](https://stackoverflow.com/questions/14284472/laravel-4-model-class-not-found))

Answer: 
I was having the same "Class [class name] not found" error message, but it wasn't a namespace issue. All my namespaces were set up correctly. I even tried `composer dump-autoload` and it didn't help me.

Surprisingly (to me) I then did `composer dump-autoload -o` which according to Composer's help, "optimizes PSR0 and PSR4 packages to be loaded with classmaps too, good for production." Somehow doing it that way got composer to behave and include the class correctly in the autoload\_classmap.php file.
For me it was really silly I had created a ModelClass file without the .php extension. So calling that was giving model not found. So check the extension has .php