Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

kevdotbadger's avatar

A model as App/Models/Client.php not accessibly via use App\Models\Client;

Hello, as the title suggests. I have a Client.php model class under App/Models. However, when I put 'use App\Models\Client;' in my controller I get a 'Class 'App\Models\Client' not found' error.

However, if move the Client.php class to App/ the code still works. Is there some crazy cacheing going on somewhere that's not updating my file directory?

0 likes
5 replies
toniperic's avatar

Can you post the contents of your Client.php file?

It has to start like this

<?php namespace App\Models;

class Client {
// your code
}
kevdotbadger's avatar

Looks pretty much like that (it's a very basic model)

namespace App;

use Illuminate\Database\Eloquent\Model;

class Client extends Model {

    protected $fillable = [
        'name'
    ];

}
michaeldyrynda's avatar

The namespace has to be App\Models and the file needs to be app/Models/Client.php

toniperic's avatar
Level 30

As I've previously mentioned you have to change

namespace App;

to

namespace App\Models;
kevdotbadger's avatar

Thanks derringer and toniperic. I saw the issues as soon as toniperic posted his sample code! That solves the problem!

Please or to participate in this conversation.