Support the ongoing development of →
Database Packages Architecture
Last updated 2 years ago.

Could you elaborate? Do you mean you have a model class in your package, which you want to instantiate or extend in your application? If so, presuming your have namespaced your package correctly, you can just:

new \Developer\Package\Model();


class MyCustomModel extends \Developer\Package\Model 

or you can

use \Developer\Package\Model;
    new Model();

or if you really want to...

use \Developer\Package\Model as MyCustomModel;
    new MyCustomModel;
Last updated 2 years ago.

This is exactly what I need, thank you !

But my package is not loaded by default, so the new \Developer\Package\Model() crashes. Any idea ?

I use laravel 4.1.25

Last updated 2 years ago.

Ok you need to tell composer to load your package classes into the autoloader by sounds of it. I created a libraries folder in my app directory for holding my non-repository local packages for a project (most of my packages start here, then move into workbench where i finish them off and move them into a private repository for loading as a vendor package). Obviously it depends on your package location, but this is what you need to add to your main composer.json (edit it to make it work for your setup ofcourse)

"autoload": {
		"classmap": [
		"psr-0": {
			"LeeSherwood\\Http" : "app/libraries",
			"LeeSherwood\\Facebook" : "app/libraries"

Note: the path added to end of class map, and the psr-0 object are what you need.

Once done just do:

php artisan dump-autoload

and it should recompile the classloader to include your package

Last updated 2 years ago.

Thank you, it works perfectly nice ! :-)

Last updated 2 years ago.

Sign in to participate in this thread!


Your banner here too?

gpaucot gpaucot Joined 16 Apr 2014


We'd like to thank these amazing companies for supporting us

Your logo here?

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 - All rights reserved.