samedi 19 mars 2016

Is it possible to load aliases of a required package from within my package's service provider?

Let's say I am developing a L5 package, and said package uses (and requires on its own composer.json) another package which provides some aliases.

Is there a way to load the aliases from within the register() function of my service provider?

An example would be a package that uses laravelcollective/html and, on its service provider has, on the register() function, something like this:

    public function register()
    {
        // Whatever else...
        $this->app->register('Collective\Html\HtmlServiceProvider');

        // And then I'm looking for something like the following
        // $this->app->alias('HTML', 'Collective\Html\HtmlFacade');
        // $this->app->alias('Form', 'Collective\Html\FormFacade');
    }

This way the user doesn't have to add the aliases to its app config file and they can actually be used for my own tests with something like testbench.

Thanks!



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire