The Laravel Package Tools package by Spatie added a nifty feature we wanted to help share with the community: streamlined install commands for Laravel packages.
Typically, when installing a Laravel community package, the README will have instructions for publishing config files, migrations, etc. With Laravel Package Tools, you can now define a dedicated install command to automate all that:
$package ->name('your-package') ->hasConfigFile() ->hasInstallCommand(function(InstallCommand $command) { $command ->publishConfigFile() ->publishMigrations() ->askToRunMigrations() ->copyAndRegisterServiceProviderInApp() ->askToStarRepoOnGitHub(); });
Using a dedicated install command, your users only need to run one command instead of manually doing everyday installation tasks. Using the above package name, that would look like:
php artisan your-package:install
The install command feature also includes startWith()
and endWith()
methods to add custom functionality to your install command.
Neat!
To get started with this package, check out spatie/laravel-package-tools on GitHub. Also, check out Creating installer commands for Laravel packages by the author Freek Van der Herten for background details of why this feature was added, including examples.
0 comments:
Post a Comment
Thanks