overtrue / laravel-package
Laravel package template
Fund package maintenance!
Requires
- php: ^8.4
- laravel/framework: ^13.30
Requires (Dev)
- jetbrains/phpstorm-attributes: ^1.0
- laravel/pint: ^1.24
- mockery/mockery: ^1.6
- orchestra/testbench: ^11.0
- phpstan/phpstan: ^2.0
- phpunit/phpunit: ^12.5.22
- vimeo/psalm: ^6.0
Suggests
None
Provides
None
Conflicts
None
Replaces
None
This package is auto-updated.
Last update: 2026-10-09 18:21:04 UTC
README
Laravel package template.
Requirements
- PHP 8.4 or 8.5
- Laravel 13.30 or later in the 13.x series
- Composer 2
Create your package
Use GitHub's Use this template button to create your own repository, then clone it. This repository is a starting point for a package, with no application features of its own.
Before installing dependencies:
- In
composer.json, replaceovertrue/laravel-packagewith your Composer package name, and update the description, author and license as appropriate. - Replace
Overtrue\LaravelPackagewith your namespace insrc/,tests/and the Composer autoload and discovery settings. Remember that backslashes are escaped in JSON. Keep the provider class name consistent if you renamePackageServiceProvider. - Update this README, repository links and sponsorship settings for your package.
composer install
composer fix-style
composer test
composer check-style
composer test-smoke
Run composer fix-style after renaming to update namespace import ordering.
The smoke test requires network access and SQLite support. It creates a temporary, renamed package, installs it into a fresh Laravel 13 application through a Composer path repository, and checks automatic discovery, migration publishing and database behavior. Its sample migration is created only in the temporary package.
Package development
src/PackageServiceProvider.php is automatically discovered by Laravel through extra.laravel.providers in composer.json. Add your package's implementation in src/, and replace or extend the example tests in tests/.
Migrations
The migrations/ directory is initially empty. Add your package's migrations there when needed. The service provider registers that directory with Laravel's migrator for console commands, so application users can run:
php artisan migrate
Users can also publish your migrations into their application's database/migrations directory. Use your renamed provider in this command:
php artisan vendor:publish --provider="Overtrue\LaravelPackage\PackageServiceProvider" --tag=migrations
No configuration files or events are included. Add and document them if your package needs them. The SQLite migration and model under tests/ are test fixtures, not application migrations.
Test in an application
In a separate Laravel 13 application, point Composer at your package's local directory (replace the path and package name):
composer config repositories.local-package path ../your-package composer require your-vendor/your-package:@dev
Composer will install the package and Laravel will discover its provider. Test your actual application integration before publishing a release.
❤️ Sponsor me
如果你喜欢我的项目并想支持它,点击这里 ❤️
Contributing
You can contribute in one of three ways:
- File bug reports using the issue tracker.
- Answer questions or fix bugs on the issue tracker.
- Contribute new features or update the wiki.
The code contribution process is not very formal. You just need to make sure that you run composer test, composer check-style, and composer test-smoke before submitting changes. Any new code contributions must be accompanied by unit tests where applicable.
Project supported by JetBrains
Many thanks to Jetbrains for kindly providing a license for me to work on this and other open-source projects.
License
MIT