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

gutenburg's avatar

Model class not found (even though namespace is right)

I have a Model class and it has a namespace of: namespace App\Taxes;

Taxes.php class is in the app directory.

I have this at the top of the controller: use App\Taxes\Taxes; (PHPStorm imports the class with no errors)

And I instantiate the class: $taxes = new Taxes();

But I get this error: FatalErrorException in TaxesController.php line 20: Class 'App\Taxes\Taxes' not found

It worked fine before with no problems and no changes since. I can't think of anything that would cause this.

0 likes
1 reply
gutenburg's avatar

Well, I changed the namespace of the model to just

namespace App;

and changed the code in the controller to

use App\Taxes;

and now it works fine. It's strange though that it worked this way before. I always figure things out as soon as I post a question!

1 like

Please or to participate in this conversation.