gnu / scaffy-laravel
Laravel adapters for the Scaffy/Core package.
v1.7.1
2025-07-10 14:18 UTC
Requires
- php: >=8.0
- gnu/scaffy-core: ^1.1
- illuminate/console: ^10.0 || ^11.0
- illuminate/support: ^10.0 || ^11.0
README
Scaffy Laravel is a Laravel-specific adapter for the Scaffy Core code generation system. It provides an Artisan command to generate Eloquent models directly from your database schema.
โจ Features
- ๐ฏ Generate models from SQL Server, PostgreSQL, or MySQL
- ๐ Fully decoupled via Hexagonal Architecture
- ๐ Analyzes your database structure using Laravel's DB layer
- โ๏ธ Pluggable support for custom adapters and databases
- ๐ ๏ธ Uses Laravel's Artisan Console Command
๐ Installation
composer require gnu/scaffy-laravel
Scaffy Laravel will be auto-discovered by Laravel.
๐ฆ Requirements
- PHP 8.1+
- Laravel 10, 11, or 12
- One of:
- SQL Server (
sqlsrv
) - PostgreSQL (
pgsql
) - MySQL (
mysql
)
- SQL Server (
๐งฐ Usage
php artisan scaffy:generate --schema=your_schema
Options
Option | Description |
---|---|
--schema |
The database schema to use |
--table |
Only generate a model for a specific table |
--output |
(Coming soon) Output path for generated models (default: app/Models ) |
--with-relations |
(Coming soon) Generate relationships between models |
โ๏ธ Configuration & Binding
Scaffy binds a default database adapter based on your DB_CONNECTION
.
To override or extend:
use Gnu\Scaffy\Laravel\Ports\DatabasePort; use App\Adapters\CustomPostgresAdapter; $this->app->bind(DatabasePort::class, fn () => new CustomPostgresAdapter());
๐งฑ Architecture
Scaffy follows Hexagonal Architecture:
scaffy-core
: Business logic & interfacesscaffy-laravel
: Laravel integration (command, container)- Future: CLI, Symfony, CodeIgniter, standalone PHP
๐งช Example Output
namespace App\Models; use Illuminate\Database\Eloquent\Model; class User extends Model { protected $fillable = [ 'id', 'name', 'email' ]; public $timestamps = false; public function getTable() { return 'dbo.users'; } }
๐ License
MIT ยฉ gnujesus