{"id":13608669,"url":"https://github.com/spatie/laravel-package-tools","last_synced_at":"2025-04-23T20:46:16.609Z","repository":{"id":36997290,"uuid":"332291650","full_name":"spatie/laravel-package-tools","owner":"spatie","description":"Tools for creating Laravel packages","archived":false,"fork":false,"pushed_at":"2025-04-11T15:28:07.000Z","size":365,"stargazers_count":851,"open_issues_count":2,"forks_count":157,"subscribers_count":11,"default_branch":"main","last_synced_at":"2025-04-22T03:39:58.722Z","etag":null,"topics":["laravel","package","php"],"latest_commit_sha":null,"homepage":"https://freek.dev/1886-simplifying-service-providers-in-laravel-packages","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/spatie.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null},"funding":{"github":"spatie"}},"created_at":"2021-01-23T19:30:07.000Z","updated_at":"2025-04-15T23:44:38.000Z","dependencies_parsed_at":"2024-02-26T01:49:10.755Z","dependency_job_id":"5d72a05c-3da2-46ee-bbb0-dda71fea0f30","html_url":"https://github.com/spatie/laravel-package-tools","commit_stats":{"total_commits":265,"total_committers":52,"mean_commits":5.096153846153846,"dds":"0.49433962264150944","last_synced_commit":"d780aa11356d337d750391e060636ce5bdc6ecda"},"previous_names":[],"tags_count":70,"template":false,"template_full_name":"spatie/package-skeleton-laravel","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/spatie%2Flaravel-package-tools","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/spatie%2Flaravel-package-tools/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/spatie%2Flaravel-package-tools/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/spatie%2Flaravel-package-tools/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/spatie","download_url":"https://codeload.github.com/spatie/laravel-package-tools/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250513382,"owners_count":21443200,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["laravel","package","php"],"created_at":"2024-08-01T19:01:29.092Z","updated_at":"2025-04-23T20:46:16.602Z","avatar_url":"https://github.com/spatie.png","language":"PHP","funding_links":["https://github.com/sponsors/spatie"],"categories":["PHP","Popular Packages"],"sub_categories":[],"readme":"\u003cdiv align=\"left\"\u003e\n    \u003ca href=\"https://spatie.be/open-source?utm_source=github\u0026utm_medium=banner\u0026utm_campaign=laravel-package-tools\"\u003e\n      \u003cpicture\u003e\n        \u003csource media=\"(prefers-color-scheme: dark)\" srcset=\"https://spatie.be/packages/header/laravel-package-tools/html/dark.webp\"\u003e\n        \u003cimg alt=\"Logo for laravel-package-tools\" src=\"https://spatie.be/packages/header/laravel-package-tools/html/light.webp\" height=\"190\"\u003e\n      \u003c/picture\u003e\n    \u003c/a\u003e\n\n\u003ch1\u003eTools for creating Laravel packages\u003c/h1\u003e\n\n[![Latest Version on Packagist](https://img.shields.io/packagist/v/spatie/laravel-package-tools.svg?style=flat-square)](https://packagist.org/packages/spatie/laravel-package-tools)\n![Tests](https://github.com/spatie/laravel-package-tools/workflows/Tests/badge.svg)\n[![Total Downloads](https://img.shields.io/packagist/dt/spatie/laravel-package-tools.svg?style=flat-square)](https://packagist.org/packages/spatie/laravel-package-tools)\n\n\u003c/div\u003e\n\nThis package contains a `PackageServiceProvider` that you can use in your packages to easily register config files,\nmigrations, and more.\n\nHere's an example of how it can be used.\n\n```php\nuse Spatie\\LaravelPackageTools\\PackageServiceProvider;\nuse Spatie\\LaravelPackageTools\\Package;\nuse MyPackage\\ViewComponents\\Alert;\nuse Spatie\\LaravelPackageTools\\Commands\\Concerns;\n\nclass YourPackageServiceProvider extends PackageServiceProvider\n{\n    public function configurePackage(Package $package): void\n    {\n        $package\n            -\u003ename('your-package-name')\n            -\u003ehasConfigFile()\n            -\u003ehasViews()\n            -\u003ehasViewComponent('spatie', Alert::class)\n            -\u003ehasViewComposer('*', MyViewComposer::class)\n            -\u003esharesDataWithAllViews('downloads', 3)\n            -\u003ehasTranslations()\n            -\u003ehasAssets()\n            -\u003epublishesServiceProvider('MyProviderName')\n            -\u003ehasRoute('web')\n            -\u003ehasMigration('create_package_tables')\n            -\u003ehasCommand(YourCoolPackageCommand::class)\n            -\u003ehasInstallCommand(function(InstallCommand $command) {\n                $command\n                    -\u003epublishConfigFile()\n                    -\u003epublishAssets()\n                    -\u003epublishMigrations()\n                    -\u003ecopyAndRegisterServiceProviderInApp()\n                    -\u003easkToStarRepoOnGitHub();\n            });\n    }\n}\n```\n\nUnder the hood it will do the necessary work to register the necessary things and make all sorts of files publishable.\n\n## Support us\n\n[\u003cimg src=\"https://github-ads.s3.eu-central-1.amazonaws.com/laravel-package-tools.jpg?t=1\" width=\"419px\" /\u003e](https://spatie.be/github-ad-click/laravel-package-tools)\n\nWe invest a lot of resources into creating [best in class open source packages](https://spatie.be/open-source). You can\nsupport us by [buying one of our paid products](https://spatie.be/open-source/support-us).\n\nWe highly appreciate you sending us a postcard from your hometown, mentioning which of our package(s) you are using.\nYou'll find our address on [our contact page](https://spatie.be/about-us). We publish all received postcards\non [our virtual postcard wall](https://spatie.be/open-source/postcards).\n\n## Getting started\n\nThis package is opinionated on how you should structure your package. To get started easily, consider\nusing [our package-skeleton repo](https://github.com/spatie/package-skeleton-laravel) to start your package. The\nskeleton is structured perfectly to work perfectly with the `PackageServiceProvider` in this package.\n\n## Usage\n\nTo avoid needing to scroll through to find the right usage section, here is a Table of Contents:\n\n* [Directory Structure](#directory-structure)\n* [Making your functionality publishable](#making-your-functionality-publishable)\n* [Getting Started](#getting-started)\n* [Assets](#assets)\n* [Blade Components](#blade-view-components)\n* [Blade Anonymous Components](#blade-anonymous-components)\n* [Blade Custom Directives](#blade-custom-directives)\n* [Blade Custom Echo Handlers](#blade-custom-echo-handlers)\n* [Blade Custom Conditionals](#blade-custom-conditionals)\n* [Commands - Callable and Console](#commands-callable-and-console)\n* [Optimize Commands (Laravel v11+)](#optimize-commands)\n* [Config Files](#config-files)\n* [Events \u0026 Listeners](#events-and-listeners)\n* [Inertia Components](#inertia-components)\n* [Livewire Views and Components](#livewire-views-and-components)\n* [Database Migrations](#database-migrations)\n* [Routes](#routes)\n* [Publishable Service Providers](#publishable-service-providers)\n* [Translations](#translations)\n* [Views](#views)\n* [View Composers](#view-composers)\n* [Views Global Shared Data](#views-global-shared-data)\n* [Creating and Install Command](#creating-an-install-command)\n* [Lifecycle Hooks](#lifecycle-hooks)\n\n### Directory Structure\n\nThis package is opinionated on how you should structure your package,\nand by default expects a structure based on\n[our package-skeleton repo](https://github.com/spatie/package-skeleton-laravel),\nand to get started easily you should consider using this to start your package.\n\nThe structure for a package expected by default looks like this:\n\n```\n\u003croot\n\u003cpackage root\u003e/src/                       Default location for PackageServiceProvider extended class\n\u003cpackage root\u003e/src/Commands/              Commands (callable and console-only)\n\u003cpackage root\u003e/src/Components/            Blade components\n\u003cpackage root\u003e/src/Providers/             Other Service Providers\n\u003cpackage root\u003e/config/                    Mergeable and publishable config files\n\u003cpackage root\u003e/database/factories/        Database factories\n\u003cpackage root\u003e/database/migrations/       Publishable stubs and loadable migrations\n\u003cpackage root\u003e/resources/dist/            Publishable assets\n\u003cpackage root\u003e/resources/js/pages/        Inertia views\n\u003cpackage root\u003e/resources/lang/            International translations\n\u003cpackage root\u003e/resources/views/           Views\n\u003cpackage root\u003e/routes/                    Routes\n```\n\nNote: When using paths in any Package method except `discoversMigrations()`,\nthe path given is relative to the location of your primary Service Provider\ni.e. relative to `\u003cpackage root\u003e/src`\nso e.g. `\u003cpackage root\u003e/ConfigFiles` would be specified as `../ConfigFiles`.\n\n### Getting Started\n\nIn your package you should let your service provider extend `Spatie\\LaravelPackageTools\\PackageServiceProvider`.\n\n```php\nuse Spatie\\LaravelPackageTools\\PackageServiceProvider;\nuse Spatie\\LaravelPackageTools\\Package;\n\nclass YourPackageServiceProvider extends PackageServiceProvider\n{\n    public function configurePackage(Package $package) : void\n    {\n        $package-\u003ename('your-package-name');\n    }\n}\n```\n\nDefining your package name with a call to `name()` is mandatory.\n\n**Note:** If your package name starts with `laravel-` then this prefix will be omitted\nand the remainder of the name used as a short-name instead when publishing files etc.\n\nAnd now let's look at all the different Laravel functions this supports...\n\nassing the package name to `name` is mandatory.\n\n### Assets\n\nAny assets your package provides, should be placed in the `\u003cpackage root\u003e/resources/dist/` directory.\n\nYou can make these assets publishable the `hasAssets` method.\n\n```php\n$package\n    -\u003ename('your-package-name')\n    -\u003ehasAssets();\n```\n\nUsers of your package will be able to publish the assets with this command:\n\n```bash\nphp artisan vendor:publish --tag=your-package-name-assets\n```\n\nThis will copy over the assets to the `public/vendor/\u003cyour-package-name\u003e` directory in the app where your package is\ninstalled in.\n\n### Blade view components\n\nAny Blade view components that your package provides should be placed in the `\u003cpackage root\u003e/src/Components` directory.\n\nYou can register these views with the `hasViewComponents` command.\n\n```php\n$package\n    -\u003ename('your-package-name')\n    -\u003ehasViewComponents('spatie', Alert::class);\n```\n\nThis will register your view components with Laravel. In the case of `Alert::class`, it can be referenced in views\nas `\u003cx-spatie-alert /\u003e`, where `spatie` is the prefix you provided during registration.\n\nCalling `hasViewComponents` will also make view components publishable, and will be published\nto `app/Views/Components/vendor/\u003cpackage name\u003e`.\n\nUsers of your package will be able to publish the view components with this command:\n\n```bash\nphp artisan vendor:publish --tag=your-package-name-components\n```\n\n### Commands - Callable and Console\n\nYou can register any command you package provides with the `hasCommand` function.\n\n```php\n$package\n    -\u003ename('your-package-name')\n    -\u003ehasCommand(YourCoolPackageCommand::class);\n````\n\nIf your package provides multiple commands, you can either use `hasCommand` multiple times, or pass an array\nto `hasCommands`\n\n```php\n$package\n    -\u003ename('your-package-name')\n    -\u003ehasCommands([\n        YourCoolPackageCommand::class,\n        YourOtherCoolPackageCommand::class,\n    ]);\n```\n\n### Config Files\n\nTo register a config file, you should create a php file with your package name in the `config` directory of your\npackage. In this example it should be at `\u003cpackage root\u003e/config/your-package-name.php`.\n\nIf your package name starts with `laravel-`, we expect that your config file does not contain that prefix. So if your\npackage name is `laravel-cool-package`, the config file should be named `cool-package.php`.\n\nTo register that config file, call `hasConfigFile()` on `$package` in the `configurePackage` method.\n\n```php\n$package\n    -\u003ename('your-package-name')\n    -\u003ehasConfigFile();\n```\n\nThe `hasConfigFile` method will also make the config file publishable. Users of your package will be able to publish the\nconfig file with this command.\n\n```bash\nphp artisan vendor:publish --tag=your-package-name-config\n```\n\nShould your package have multiple config files, you can pass their names as an array to `hasConfigFile`\n\n```php\n$package\n    -\u003ename('your-package-name')\n    -\u003ehasConfigFile(['my-config-file', 'another-config-file']);\n```\n\n### Inertia Components\n\nAny `.vue` or `.jsx` files your package provides, should be placed in the `\u003cpackage root\u003e/resources/js/Pages` directory.\n\nYou can register these components with the `hasInertiaComponents` command.\n\n```php\n$package\n    -\u003ename('your-package-name')\n    -\u003ehasInertiaComponents();\n```\n\nThis will register your components with Laravel.\n\nThe user should publish the inertia components manually or using the [installer-command](#adding-an-installer-command) in order to use them.\n\nIf you have an inertia component `\u003cpackage root\u003e/resources/js/Pages/myComponent.vue`, you can use it like\nthis: `Inertia::render('YourPackageName/myComponent')`. Of course, you can also use subdirectories to organise your components.\n\n#### Publishing inertia components\n\nCalling `hasInertiaComponents` will also make inertia components publishable. Users of your package will be able to publish the views with this\ncommand:\n\n```bash\nphp artisan vendor:publish --tag=your-package-name-inertia-components\n```\n\nAlso, the inertia components are available in a convenient way with your package [installer-command](#adding-an-installer-command)\n\n### Working with migrations\n\nThe `PackageServiceProvider` assumes that any migrations are placed in this\ndirectory: `\u003cpackage root\u003e/database/migrations`. Inside that directory you can put any migrations.\n\nTo register your migration, you should pass its name without the extension to the `hasMigration` table.\n\nIf your migration file is called `create_my_package_tables.php.stub` you can register them like this:\n\n```php\n$package\n    -\u003ename('your-package-name')\n    -\u003ehasMigration('create_my_package_tables');\n```\n\nShould your package contain multiple migration files, you can just call `hasMigration` multiple times or\nuse `hasMigrations`.\n\n```php\n$package\n    -\u003ename('your-package-name')\n    -\u003ehasMigrations(['my_package_tables', 'some_other_migration']);\n```\n\nAlternatively, if you wish to publish all migrations in your package by default, you may call `discoversMigrations`.\n\n```php\n$package\n    -\u003ename('your-package-name')\n    -\u003ediscoversMigrations();\n```\n\nCalling this method will look for migrations in the `./database/migrations` directory of your project. However, if you have defined your migrations\nin a different folder, you may pass a value to the `$path` variable to instruct the app to discover migrations from that location.\n\n```php\n$package\n    -\u003ename('your-package-name')\n    -\u003ediscoversMigrations(path: '/path/to/your/migrations/folder');\n```\n\nCalling either `hasMigration`, `hasMigration` or `discoversMigrations` will also make migrations publishable. Users of your package will be able to publish the\nmigrations with this command:\n\n```bash\nphp artisan vendor:publish --tag=your-package-name-migrations\n```\n\nLike you might expect, published migration files will be prefixed with the current datetime.\n\nYou can also enable the migrations to be registered without needing the users of your package to publish them:\n\n```php\n$package\n    -\u003ename('your-package-name')\n    -\u003ehasMigrations(['my_package_tables', 'some_other_migration'])\n    -\u003erunsMigrations();\n```\n\n### Routes\n\nThe `PackageServiceProvider` assumes that any route files are placed in this directory: `\u003cpackage root\u003e/routes`. Inside\nthat directory you can put any route files.\n\nTo register your route, you should pass its name without the extension to the `hasRoute` method.\n\nIf your route file is called `web.php` you can register them like this:\n\n```php\n$package\n    -\u003ename('your-package-name')\n    -\u003ehasRoute('web');\n```\n\nShould your package contain multiple route files, you can just call `hasRoute` multiple times or use `hasRoutes`.\n\n```php\n$package\n    -\u003ename('your-package-name')\n    -\u003ehasRoutes(['web', 'admin']);\n```\n\n### Publishable Service Providers\n\nSome packages need an example service provider to be copied into the `app\\Providers` directory of the Laravel app. Think\nof for instance, the `laravel/horizon` package that copies an `HorizonServiceProvider` into your app with some sensible\ndefaults.\n\n```php\n$package\n    -\u003ename('your-package-name')\n    -\u003epublishesServiceProvider($nameOfYourServiceProvider);\n```\n\nThe file that will be copied to the app should be stored in your package\nin `/resources/stubs/{$nameOfYourServiceProvider}.php.stub`.\n\nWhen your package is installed into an app, running this command...\n\n```bash\nphp artisan vendor:publish --tag=your-package-name-provider\n```\n\n... will copy `/resources/stubs/{$nameOfYourServiceProvider}.php.stub` in your package\nto `app/Providers/{$nameOfYourServiceProvider}.php` in the app of the user.\n\n### Translations\n\nAny translations your package provides, should be placed in the `\u003cpackage root\u003e/resources/lang/\u003clanguage-code\u003e`\ndirectory.\n\nYou can register these translations with the `hasTranslations` command.\n\n```php\n$package\n    -\u003ename('your-package-name')\n    -\u003ehasTranslations();\n```\n\nThis will register the translations with Laravel.\n\nAssuming you save this translation file at `\u003cpackage root\u003e/resources/lang/en/translations.php`...\n\n```php\nreturn [\n    'translatable' =\u003e 'translation',\n];\n```\n\n... your package and users will be able to retrieve the translation with:\n\n```php\ntrans('your-package-name::translations.translatable'); // returns 'translation'\n```\n\nIf your package name starts with `laravel-` then you should leave that off in the example above.\n\nCoding with translation strings as keys, you should create JSON files\nin `\u003cpackage root\u003e/resources/lang/\u003clanguage-code\u003e.json`.\n\nFor example, creating `\u003cpackage root\u003e/resources/lang/it.json` file like so:\n\n```json\n{\n    \"Hello!\": \"Ciao!\"\n}\n```\n\n...the output of...\n\n```php\ntrans('Hello!');\n```\n\n...will be `Ciao!` if the application uses the Italian language.\n\nCalling `hasTranslations` will also make translations publishable. Users of your package will be able to publish the\ntranslations with this command:\n\n```bash\nphp artisan vendor:publish --tag=your-package-name-translations\n```\n\n### Views\n\nAny views your package provides, should be placed in the `\u003cpackage root\u003e/resources/views` directory.\n\nYou can register these views with the `hasViews` command.\n\n```php\n$package\n    -\u003ename('your-package-name')\n    -\u003ehasViews();\n```\n\nThis will register your views with Laravel.\n\nIf you have a view `\u003cpackage root\u003e/resources/views/myView.blade.php`, you can use it like\nthis: `view('your-package-name::myView')`. Of course, you can also use subdirectories to organise your views. A view\nlocated at `\u003cpackage root\u003e/resources/views/subdirectory/myOtherView.blade.php` can be used\nwith `view('your-package-name::subdirectory.myOtherView')`.\n\n#### Using a custom view namespace\n\nYou can pass a custom view namespace to the `hasViews` method.\n\n```php\n$package\n    -\u003ename('your-package-name')\n    -\u003ehasViews('custom-view-namespace');\n```\n\nYou can now use the views of the package like this:\n\n```php\nview('custom-view-namespace::myView');\n```\n\n#### Publishing the views\n\nCalling `hasViews` will also make views publishable. Users of your package will be able to publish the views with this\ncommand:\n\n```bash\nphp artisan vendor:publish --tag=your-package-name-views\n```\n\n\u003e **Note:**\n\u003e\n\u003e If you use custom view namespace then you should change your publish command like this:\n```bash\nphp artisan vendor:publish --tag=custom-view-namespace-views\n```\n\n### View Composers\n\nYou can register any view composers that your project uses with the `hasViewComposers` method. You may also register a\ncallback that receives a `$view` argument instead of a classname.\n\nTo register a view composer with all views, use an asterisk as the view name `'*'`.\n\n```php\n$package\n    -\u003ename('your-package-name')\n    -\u003ehasViewComposer('viewName', MyViewComposer::class)\n    -\u003ehasViewComposer('*', function($view) {\n        $view-\u003ewith('sharedVariable', 123);\n    });\n```\n\n### Views Global Shared Data\n\nYou can share data with all views using the `sharesDataWithAllViews` method. This will make the shared variable\navailable to all views.\n\n```php\n$package\n    -\u003ename('your-package-name')\n    -\u003esharesDataWithAllViews('companyName', 'Spatie');\n```\n\n### Creating an Install Command\n\nInstead of letting your users manually publishing config files, migrations, and other files manually, you could opt to\nadd an install command that does all this work in one go. Packages like Laravel Horizon and Livewire provide such\ncommands.\n\nWhen using Laravel Package Tools, you don't have to write an `InstallCommand` yourself. Instead, you can simply\ncall, `hasInstallCommand` and configure it using a closure. Here's an example.\n\n```php\nuse Spatie\\LaravelPackageTools\\PackageServiceProvider;\nuse Spatie\\LaravelPackageTools\\Package;\nuse Spatie\\LaravelPackageTools\\Commands\\Concerns;\n\nclass YourPackageServiceProvider extends PackageServiceProvider\n{\n    public function configurePackage(Package $package): void\n    {\n        $package\n            -\u003ename('your-package-name')\n            -\u003ehasConfigFile()\n            -\u003ehasMigration('create_package_tables')\n            -\u003epublishesServiceProvider('MyServiceProviderName')\n            -\u003ehasInstallCommand(function(InstallCommand $command) {\n                $command\n                    -\u003epublishConfigFile()\n                    -\u003epublishAssets()\n                    -\u003epublishMigrations()\n                    -\u003easkToRunMigrations()\n                    -\u003ecopyAndRegisterServiceProviderInApp()\n                    -\u003easkToStarRepoOnGitHub('your-vendor/your-repo-name')\n            });\n    }\n}\n```\n\nWith this in place, the package user can call this command:\n\n```bash\nphp artisan your-package-name:install\n```\n\nUsing the code above, that command will:\n\n- publish the config file\n- publish the assets\n- publish the migrations\n- copy the `/resources/stubs/MyProviderName.php.stub` from your package to `app/Providers/MyServiceProviderName.php`, and also register that\n  provider in `config/app.php`\n- ask if migrations should be run now\n- prompt the user to open up `https://github.com/'your-vendor/your-repo-name'` in the browser in order to star it\n\nYou can also call `startWith` and `endWith` on the `InstallCommand`. They will respectively be executed at the start and\nend when running `php artisan your-package-name:install`. You can use this to perform extra work or display extra\noutput.\n\n```php\nuse Spatie\\LaravelPackageTools\\Commands\\Concerns;\n\npublic function configurePackage(Package $package): void\n{\n    $package\n        // ... configure package\n        -\u003ehasInstallCommand(function(InstallCommand $command) {\n            $command\n                -\u003estartWith(function(InstallCommand $command) {\n                    $command-\u003einfo('Hello, and welcome to my great new package!');\n                })\n                -\u003epublishConfigFile()\n                -\u003epublishAssets()\n                -\u003epublishMigrations()\n               -\u003easkToRunMigrations()\n                -\u003ecopyAndRegisterServiceProviderInApp()\n                -\u003easkToStarRepoOnGitHub('your-vendor/your-repo-name')\n                -\u003eendWith(function(InstallCommand $command) {\n                    $command-\u003einfo('Have a great day!');\n                })\n        });\n}\n```\n\n### Lifecycle Hooks\n\nYou can put any custom logic your package needs while starting up in one of these methods:\n\n- `registeringPackage`: will be called at the start of the `register` method of `PackageServiceProvider`\n- `packageRegistered`: will be called at the end of the `register` method of `PackageServiceProvider`\n- `bootingPackage`: will be called at the start of the `boot` method of `PackageServiceProvider`\n- `packageBooted`: will be called at the end of the `boot` method of `PackageServiceProvider`\n\n## Testing\n\n```bash\ncomposer test\n```\n\nThis package now supports test groups as follows:\n\n```bash\ncomposer test -- --group=blade\n```\n\nThe current groups suported are:\n* base\n* assets\n* blade\n* commands\n* config\n* inertia\n* migrations\n* provider\n* routes\n* shareddata\n* translations\n* viewcomposer\n* views\n* installer\n\nAdditionally, if you wish to test only backwards compatibility you can use:\n* legacy\n\n**Note:** `InvalidPackage` exceptions thrown during Laravel application bootup are reported by Pest,\nbut because the occur before the start of a test case\nPest by default does not allow you intentionally to test for them being thrown.\nThe tests in this package now include checks for intentional `InvalidPackage` exceptions being thrown\nby catching and saving such exceptions in the TestServiceProvider,\nand then rethrowing the exception at the very start of a Pest test case,\nand this is achieved by loading a modified version of the Pest `test()` function\nbefore anything else is loaded.\nWhilst this is done for you if you run `composer test`,\nif you want to run `vendor/bin/pest` directly you now need to run it like this:\n\n```bash\nphp -d auto_prepend_file=tests/Prepend.php vendor/bin/pest\n```\n\n## Changelog\n\nPlease see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.\n\n## Contributing\n\nPlease see [CONTRIBUTING](https://github.com/spatie/.github/blob/main/CONTRIBUTING.md) for details.\n\n## Security Vulnerabilities\n\nPlease review [our security policy](../../security/policy) on how to report security vulnerabilities.\n\n## Credits\n\n- [Freek Van der Herten](https://github.com/freekmurze)\n- [All Contributors](../../contributors)\n\n## License\n\nThe MIT License (MIT). Please see [License File](LICENSE.md) for more information.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fspatie%2Flaravel-package-tools","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fspatie%2Flaravel-package-tools","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fspatie%2Flaravel-package-tools/lists"}