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');
}
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.
@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.
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!
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?
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.