Published 2 months ago by tealiedie
Hi, i am not sure if this is possible in PHP namespaces. please help me
// folder structure app -- ModelsFolder // the models folder -- ComponentsFolder // some traits -- Traits::class -- User::class -- OtherModel::class
the Classes are only using the app folder as namespace
// User class <?php namespace App;
in my controllers i use the class as..
<?php namespace App\Http\Controllers; use App\User; // import class use App\OtherModel;
i wonder if this setup is possible, because it's giving me
FatalError saying the
Class 'App\User' not found.
You have it. Just look around the Laravel directories and you will see how the namespaces relate to all files. For instance,
User.php is located in the app directory, thus the namespace is
controller.php file is located in the app directory...then the Http directory...Controllers directory. The namespace is
App\Http\Controllers\. You get the drift. So, if you locate your modals in a different directory in
app, then correct the namespace accordingly.