I am trying to use laravel packages. I created MyVendor / MyPackage
Routes, controllers, filters are already working. This is a cool map of my package:
"classmap": [
"src/migrations",
"src/controllers",
"src/seeds",
"src/models"
],
This is what my model looks like:
namespace MyVendor\MyPackage\Models;
class MyModel extends \Illuminate\Database\Eloquent\Model {
}
And this is the code inside my controller, which is located in the namespace MyVendor \ MyPackage.
$test = new models\MyModel;
I get this error: Class 'MyVendor \ MyPackage \ models \ MyModel' not found
I can’t understand why. I am new to namespaces, so maybe this is due to this. I tried with the composer update, the dump-autoload linker (inside my package) and still cannot find my models.
If I get declared classes using get_declared_classes (), I don't see my model there.
The problem is that my model classes are not autoload.