• Reading time ~ 1 min
  • 19.09.2022

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.

Comments

No comments yet
Yurij Finiv

Yurij Finiv

Full stack

ABOUT

Professional Fullstack Developer with extensive experience in website and desktop application development. Proficient in a wide range of tools and technologies, including Bootstrap, Tailwind, HTML5, CSS3, PUG, JavaScript, Alpine.js, jQuery, PHP, MODX, and Node.js. Skilled in website development using Symfony, MODX, and Laravel. Experience: Contributed to the development and translation of MODX3 i...

About author CrazyBoy49z
WORK EXPERIENCE
Contact
Ukraine, Lutsk
+380979856297