| name | laravel-package-scaffold |
| description | Scaffold Laravel packages with ServiceProvider, Facade, Config, and test setup |
| allowed-tools | Bash(python3:*), Write, Read, Glob |
Laravel Package Scaffold Skill
Creates a complete Laravel package skeleton with proper structure and all necessary files.
Usage
When the user wants to create a Laravel package, use the scaffold script:
python3 ${SKILL_DIR}/scripts/scaffold_laravel_package.py <vendor/package-name> [--with-pest] [--with-facade] [--with-config] [--with-command]
Examples
Basic package
python3 ${SKILL_DIR}/scripts/scaffold_laravel_package.py mwguerra/my-package
Package with testing
python3 ${SKILL_DIR}/scripts/scaffold_laravel_package.py mwguerra/my-package --with-pest
Full-featured package
python3 ${SKILL_DIR}/scripts/scaffold_laravel_package.py mwguerra/my-package --with-pest --with-facade --with-config --with-command
What Gets Created
Directory Structure
packages/
└── vendor/
└── package-name/
├── composer.json
├── README.md
├── LICENSE
├── .gitignore
├── config/
│ └── package-name.php
├── src/
│ ├── PackageNameServiceProvider.php
│ ├── PackageName.php (main class)
│ ├── Facades/
│ │ └── PackageName.php
│ └── Commands/
│ └── InstallCommand.php
└── tests/ (if --with-pest)
├── Pest.php
├── TestCase.php
└── Unit/
└── ExampleTest.php
Generated Files
composer.json
- PSR-4 autoloading for
src/andtests/ - Laravel auto-discovery configuration
- PHP ^8.2 requirement
- Laravel ^11.0|^12.0 support (latest)
- Orchestra Testbench ^10.0 (latest)
- PestPHP ^3.8 (latest)
- PSR-4 autoloading for
ServiceProvider
- Config merging and publishing
- Command registration
- View/translation loading (prepared)
Facade (optional)
- Accessor for the main service class
Config (optional)
- Default configuration file
- Publishable via artisan
Commands (optional)
- Install command for post-install setup
Tests (optional)
- PestPHP setup with Orchestra Testbench
- Example test verifying environment
Project Integration
The script automatically updates the project's composer.json:
- Adds path repository pointing to
packages/vendor/package-name - Adds package to
requireblock as@dev - Enables symlink for development
After Running
Install dependencies:
composer updateVerify installation:
php artisan package-name:installPublish config (if applicable):
php artisan vendor:publish --tag=package-name-configRun tests (if testing was added):
cd packages/vendor/package-name composer install ./vendor/bin/pest
Naming Conventions
- Package name:
kebab-case(e.g.,my-awesome-package) - PHP namespace:
PascalCase(e.g.,MyAwesomePackage) - Config key:
kebab-case(e.g.,my-awesome-package) - Commands:
kebab-case:action(e.g.,my-awesome-package:install)
Laravel package integration notes
- Configure package discovery via
composer.jsonextra.laravel.providers(and optionalaliases). - In the ServiceProvider:
register():mergeConfigFrom()and container bindings.boot():publishes()/publishesMigrations()plusloadRoutesFrom(),loadViewsFrom(),loadTranslationsFrom().- Tag publish groups (
package-config,package-migrations,package-views,public). - Optionally contribute to
about, and hook intooptimize/reload.