emmanpbarrameda / filament-scaffold2
Scaffold Manager for Filament v4/v5: generate migrations, models, resources, policies, controllers and API services from your panel. Based on solution-forest/filament-scaffold.
Package info
github.com/emmanpbarrameda/filament-scaffold2
pkg:composer/emmanpbarrameda/filament-scaffold2
Requires
- php: ^8.2
- filament/filament: ^4.0|^5.0
- illuminate/contracts: ^11.0|^12.0|^13.0
- spatie/laravel-package-tools: ^1.15
Requires (Dev)
- laravel/pint: ^1.0
- nunomaduro/collision: ^7.9|^8.0
- nunomaduro/larastan: ^2.0.1
- orchestra/testbench: ^8.0|^9.0
- pestphp/pest: ^2.1|^3.0
- pestphp/pest-plugin-arch: ^2.0|^3.0
- pestphp/pest-plugin-laravel: ^2.0|^3.0
- phpstan/extension-installer: ^1.1
- phpstan/phpstan-deprecation-rules: ^1.0
- phpstan/phpstan-phpunit: ^1.0
- spatie/laravel-ray: ^1.26
Suggests
None
Provides
None
Conflicts
None
Replaces
None
README
Description
Filament Scaffold 2 is a toolkit for Filament v4 and v5 that simplifies the generation of resources. Fill in one form inside your panel and it generates the migration, model, factory, Filament resource, controller, route, Shield policy and API service for a table. It aims to speed up development and reduce the time spent writing repetitive code.
Note
Filament Scaffold 2 is a rebuild of solution-forest/filament-scaffold, which supports Filament v3 only. It adds a new generation flow, validation of every generated name, and optional Shield and API integrations. See Credits.
Features
-
Automatic Filament Resource Generation: the migration runs first, then
make:filament-resource --generatebuilds the form and table from the real database columns, in the v4/v5 resource layout (Resource + Schemas + Tables + Pages). -
Support for Multiple Resource Types: generates the migration (and runs it), model, factory, Filament resource, controller, route, Shield policy and API service.
-
New or Existing Tables: design the columns in the form (including enum values, nullable, default, unique/index and comments), or pick an existing table to load its columns.
-
Any Database: table introspection uses Laravel's Schema builder (MySQL, MariaDB, SQLite, PostgreSQL).
-
Safe by Default: disabled unless you enable it, never overwrites existing models or policies, and rejects names that aren't valid PHP/SQL identifiers before writing anything.
-
Optional Integrations: Filament Shield policies and permissions (created by
shield:generate, so they follow your Shield config) and Filament API Service endpoints. These options only show when the packages are installed.
Requirements
- PHP 8.2+
- Laravel 11, 12 or 13
- Filament v4 or v5
Installation
Install it as a dev dependency. The Scaffold Manager writes PHP files to your project and must never be reachable in production.
composer require emmanpbarrameda/filament-scaffold2 --dev
Then, make sure your database connection is set in the .env file.
In your project, app/Providers/Filament/xxxPanelProvider.php, add the plugin:
use Emmanpbarrameda\FilamentScaffold2\FilamentScaffoldPlugin; public function panel(Panel $panel): Panel { return $panel // ... ->plugins(array_filter([ class_exists(FilamentScaffoldPlugin::class) ? FilamentScaffoldPlugin::make() : null, ])); }
The class_exists() check keeps the panel working on servers where dev dependencies are not installed (composer install --no-dev).
Enable it in your local .env only:
FILAMENT_SCAFFOLD2_ENABLED=true
Publishing Configuration file
To publish the configuration file, use:
php artisan vendor:publish --tag="filament-scaffold2-config"
return [ 'enabled' => env('FILAMENT_SCAFFOLD2_ENABLED', false), 'navigation' => [ 'group' => 'System', 'icon' => 'heroicon-o-cube-transparent', 'sort' => 99, 'label' => 'Scaffold2 Manager', ], ];
Set enabled to false (the default) to turn the Scaffold Manager off. When it is off, the page is not registered at all.
Usage
Your panel will have a System > Scaffold2 Manager page.
- New table: type a table name, add the columns, and keep "Create Migration" and "Run Migrate" checked.
- Existing table: pick it in "Choose Table". Its columns are loaded and "Create Migration" is unchecked automatically.
Click Create Scaffold. The steps run in this order:
- Migration, then
migrate - Model
- Factory
- Filament resource (
--generate, so the form and table come from the real columns) - Controller and route
- Cache clear (
optimize:clearand Filament's cached panel components, so the new resource shows up right away) - Shield policy and permissions (
shield:generatein a separate process, using yourconfig/filament-shield.phpnaming; new permissions go tosuper_admin) - API service
Existing model and policy files are never overwritten. If the table already exists, the migration step is skipped with a warning.
Note
The resource's form and table come from Filament's own make:filament-resource --generate, which picks each field and column from the database column type. Review the generated files and adjust labels, relationships and validation as needed.
Preview
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Issues and pull requests are welcome on GitHub. Please describe the Filament, Laravel and PHP versions you are using.
Security Vulnerabilities
The Scaffold Manager turns form input into PHP files. Keep it disabled outside local development. If you find a security issue, please open a private security advisory instead of a public issue.
Credits
- Emmanuel P. Barrameda: Filament v4/v5 rebuild and maintenance
- Solution Forest and the contributors of solution-forest/filament-scaffold: the original package this project is based on
- All Contributors
License
The MIT License (MIT). This project keeps the original copyright notice of solution-forest/filament-scaffold. Please see License File for more information.
