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

sohelamin's avatar

Is it best practice to include a package config to another package silently?

Hi Guys,

I've a crud generator package "appzcoder/crud-generator" which has a dependency package "laravelcollective/html" as well. My issue is, will it best practice to use 2nd package service provider into my main package? so user should not need to configure the "laravelcollective/html" package or no need to include the service provider and the aliases.

Eg:

// Registering "laravelcollective/html" into "appzcoder/crud-generator"
if (!$this->app->bound('Collective\Html\HtmlServiceProvider')) {
    $this->app->register('Collective\Html\HtmlServiceProvider');
    $loader = \Illuminate\Foundation\AliasLoader::getInstance();
    $loader->alias('Form', 'Collective\Html\FormFacade');
    $loader->alias('HTML', 'Collective\Html\HtmlFacade');
}
0 likes
6 replies
bobbybouwmann's avatar

It would be better to decouple it at all, so your package doesn't require the laravelcollective package.

I would just tell the user to include the service provider next to your own provider. This way the user can reuse the included package as well in their code.

sohelamin's avatar

@bobbybouwmann I did it as dependent the package "laravelcollective/html" for my main package "appzcoder/crud-generator" and told to user to include the service provider for the configuration. You can check it here https://github.com/appzcoder/crud-generator But peoples/users don't like to follow more instructions :( That's why I'm seeking an solution.

bobbybouwmann's avatar

The other option would be including it right away in your package service provider, but I still think it's not the best way! At least your users now know what you include for them!

sohelamin's avatar

Thanks. I will leave it there whatever it is now.

jack's avatar

what about having a script that adds the needed lines to the users config file - should be easy to parse, see if it's there yet, and if not, add it to the appropriate section?

jekinney's avatar

I personally dislike the form and html helpers. So coupling a package like that for front-end may leave a lot of potential users out anyways. Just my 2 cents. I haven't looked over your package.

Please or to participate in this conversation.