gnu/scaffy-laravel

Laravel adapters for the Scaffy/Core package.

v1.7.1 2025-07-10 14:18 UTC

This package is auto-updated.

Last update: 2025-09-10 14:44:33 UTC


README

Latest Version on Packagist License Laravel Downloads

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)

๐Ÿงฐ 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 & interfaces
  • scaffy-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