PHPackages                             ahertl/laravel-scaffold - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Framework](/categories/framework)
4. /
5. ahertl/laravel-scaffold

ActiveLibrary[Framework](/categories/framework)

ahertl/laravel-scaffold
=======================

A package to scaffold CRUD operations and services for Laravel

v1.3.0(1mo ago)034MITPHPPHP ^8.0

Since Oct 24Pushed 1mo agoCompare

[ Source](https://github.com/AherTechCode/laravel-scaffold)[ Packagist](https://packagist.org/packages/ahertl/laravel-scaffold)[ RSS](/packages/ahertl-laravel-scaffold/feed)WikiDiscussions main Synced today

READMEChangelog (1)Dependencies (5)Versions (8)Used By (0)

Laravel Scaffold — Spec-Driven API Scaffolding for Laravel
==========================================================

[](#laravel-scaffold--spec-driven-api-scaffolding-for-laravel)

> Stop rewriting CRUD. Define your backend once, generate everything else.

**Laravel Scaffold** is a developer productivity tool that generates **production-ready Laravel APIs** from either:

- an **existing database**, or
- a **simple human-readable spec file**

It is designed for developers and teams who build **many backends**, not demos.

✅ Used in production
✅ Spec-driven &amp; DB-driven
✅ Clean architecture (Services, Repositories, Requests)
✅ Safe, fast, and extensible

---

Why This Exists
---------------

[](#why-this-exists)

If you’ve built more than a few Laravel applications, you already know the pattern:

- Create models
- Write migrations
- Build repositories
- Add services
- Repeat validation rules
- Repeat again on the next project

This tool exists to **eliminate that repetition**.

Instead of writing structure over and over, you define **intent once**, and let the tool generate consistent, maintainable code.

---

Installation
------------

[](#installation)

```
composer require ahertl/laravel-scaffold
```

---

Two Ways to Use It
------------------

[](#two-ways-to-use-it)

### 1️⃣ Database-First Scaffolding (Legacy or Existing Projects)

[](#1️⃣-database-first-scaffolding-legacy-or-existing-projects)

Generate a full CRUD API directly from an existing table:

```
php artisan laravel:scaffold User --table=users --routes
```

This generates:

- Model
- Repository
- Service
- Controller
- Optional routes

Perfect for:

- legacy systems
- modernizing old databases
- inherited projects

---

### 2️⃣ Spec-Driven Scaffolding (Recommended)

[](#2️⃣-spec-driven-scaffolding-recommended)

Define your backend using a **simple text spec**:

```
user:
- name string required
- email string required unique
- password string hidden

book:
- title string
- isbn string unique
- authorId number

```

Generate everything:

```
php artisan laravel:scaffold --spec=api.spec --migration
```

### Rich Spec Syntax

[](#rich-spec-syntax)

The original simple syntax still works, but richer migration-focused specs are also supported:

```
school table:schools softDeletes:
- schoolName string:150 required
- contactEmail string:191 required unique
- contactPhone string:30 nullable index
- isActive boolean default:true

student table:students softDeletes:
- schoolId foreignId:schools required cascadeOnDelete
- admissionNumber string:60 required unique
- firstName string:100 required
- lastName string:100 required
- middleName string:100 nullable
- gender enum:male,female nullable
- meta json nullable

payment table:payments:
- schoolId foreignId:schools required cascadeOnDelete
- parentId foreignId:parents required cascadeOnDelete
- amount decimal:12,2 required
- status enum:pending,paid,failed default:pending index
- paidAt datetime nullable

```

Entity directives can add application intent beyond plain CRUD:

```
resultPublication table:result_publications:
@route result-publications
@search studentName admissionNumber
@commands PublishResult SendResultToParent
@events ResultPublished ResultSentToParent
@state Draft Published Sent
@transition Draft Published PublishResult ResultPublished
@transition Published Sent SendResultToParent ResultSentToParent
@rule PublishResult requires studentId approvedAt
@rule SendResultToParent requires guardianEmail guardianPhone
- studentId foreignId:students required cascadeOnDelete
- status enum:Draft,Published,Sent default:Draft
- studentName string:150 required
- admissionNumber string:60 required
- guardianEmail string:191 nullable
- guardianPhone string:30 nullable
- approvedAt datetime nullable

```

Behavior directives generate Laravel extension points:

- `@search` restricts repository search to allowed columns.
- `@commands` creates service and controller methods for named business actions.
- `@events` preserves event intent; CRUD methods also dispatch `ModelCreated`, `ModelUpdated`, and `ModelDeleted` events.
- `@state` documents the allowed state set.
- `@transition From To Command Event` creates command methods that validate and apply state transitions when a `status` or `state` field exists.
- `@rule Command requires fieldA fieldB` creates precondition checks before generated command methods run.
- `@route` customizes generated route prefixes when `--routes` is used.
- `@upload` opts an entity into end-to-end Excel/CSV upload generation. Without it, no import class, upload controller method, upload service method, or upload route is generated.

Upload accepts optional settings:

```
score:
@upload field:file mimes:csv,xls,xlsx max:4096
- studentId foreignId:students required
- total decimal:5,2 required

```

Supported field types include:

```
string, text, mediumText, longText, integer, int, number,
bigInteger, unsignedBigInteger, foreignId, boolean, bool,
date, datetime, timestamp, time, decimal, float, double,
json, uuid, ulid, enum

```

Supported field modifiers include:

```
required, nullable, unique, index, default:value, unsigned,
constrained, constrained:table, references:table,
cascadeOnDelete, nullOnDelete, restrictOnDelete, cascadeOnUpdate,
hidden, nativeEnum

```

Supported entity modifiers include:

```
table:custom_table_name, softDeletes

```

### Database-Agnostic Spec Mode

[](#database-agnostic-spec-mode)

Spec-driven scaffolding is intentionally database-agnostic. It does not inspect the active database connection and generated migrations use Laravel's Schema Builder instead of driver-specific SQL.

For portability, `enum:a,b,c` generates a `string` column and an `in:a,b,c` validation rule by default. If you explicitly want a native database enum column, add the `nativeEnum` modifier:

```
payment:
- status enum:pending,paid,failed default:pending
- providerStatus enum:pending,paid,failed nativeEnum default:pending

```

Database-first scaffolding may still use driver-specific introspection depending on your database driver. Use spec mode when you need portable migrations across MySQL, PostgreSQL, SQLite, and other Laravel-supported databases.

---

### Modular Monolith Output

[](#modular-monolith-output)

Standard Laravel output remains the default. To generate module-scoped code from a spec, assign entities to modules:

```
@app architecture:modular

module Academics:
student table:students:
- firstName string:100 required
- lastName string:100 required

module Billing:
payment table:payments:
@upload field:file mimes:csv,xls,xlsx max:4096
- reference string:80 required unique
- amount decimal:12,2 required
- status enum:pending,paid,failed default:pending

```

You can also assign a module on an entity:

```
student module:Academics table:students:
- firstName string:100 required

```

Or with a directive:

```
student table:students:
@module Academics
- firstName string:100 required

```

Modular generation writes files under `app/Modules/{Module}` and registers each module route file through the application's root `routes/api.php`, so fresh Laravel 11/12 apps can discover the routes.

Database-first scaffolding also supports modular output:

```
php artisan laravel:scaffold Student --table=students --module=Academics --routes
```

When the provided table does not match Laravel's conventional model table name, the generated model includes `protected $table = '...'`.

---

What Gets Generated
-------------------

[](#what-gets-generated)

From a single spec, Laravel Scaffold can generate:

- ✅ Eloquent models (fillable &amp; hidden handled)
- ✅ Services &amp; repositories
- ✅ Controllers
- ✅ Form Request validation classes
- ✅ Database migrations
- ✅ API routes (optional)

You can also generate **only migrations**:

```
php artisan laravel:scaffold --spec=api.spec --migration-only
```

---

Why Spec-Driven?
----------------

[](#why-spec-driven)

Spec-driven development ensures:

- Database schema
- Validation rules
- API structure

…all come from **one source of truth**.

This dramatically reduces:

- bugs
- inconsistencies
- onboarding time

---

Dry-Run Mode (Safe by Default)
------------------------------

[](#dry-run-mode-safe-by-default)

Preview what will be generated **without writing files**:

```
php artisan laravel:scaffold --spec=api.spec --dry-run
```

---

Example Output Structure
------------------------

[](#example-output-structure)

```
app/
 ├── Models/User.php
 ├── Services/UserService.php
 ├── Repositories/UserRepository.php
 ├── Http/
 │   ├── Controllers/UserController.php
 │   └── Requests/
 │       ├── StoreUserRequest.php
 │       └── UpdateUserRequest.php
database/
 └── migrations/

```

---

When This Tool Shines
---------------------

[](#when-this-tool-shines)

Laravel Scaffold is ideal if you:

- Build multiple Laravel backends
- Work on ERP, SaaS, or internal systems
- Want consistent architecture across projects
- Are tired of rewriting CRUD
- Want faster backend delivery without shortcuts

---

Production Use
--------------

[](#production-use)

This tool has been used in **multiple real-world projects** to:

- speed up backend delivery
- standardize API structure
- reduce boilerplate and human error

---

Philosophy
----------

[](#philosophy)

This is **not** a “magic CRUD generator”.

It enforces:

- separation of concerns
- explicit structure
- predictable output

You stay in control — the tool just removes the busy work.

---

Roadmap
-------

[](#roadmap)

Planned improvements include:

- foreign key detection
- richer spec syntax (`string:150`, `default:true`)
- OpenAPI generation
- frontend SDK scaffolding

---

Contributing
------------

[](#contributing)

This project is actively maintained and opinionated by the author.

- Bug reports and feature discussions are welcome via Issues
- Pull requests should be discussed first before implementation
- Architectural changes will be evaluated carefully to maintain consistency

The goal is to keep the tool stable, predictable, and production-ready.

Project Governance
------------------

[](#project-governance)

Laravel Scaffold follows a Benevolent Dictator For Life (BDFL) model. The maintainer retains final decision-making authority to ensure long-term consistency and quality.

---

License
-------

[](#license)

MIT

###  Health Score

42

—

FairBetter than 88% of packages

Maintenance94

Actively maintained with recent releases

Popularity7

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity49

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 89.5% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~146 days

Total

5

Last Release

32d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/15320845?v=4)[ahertl](/maintainers/ahertl)[@ahertl](https://github.com/ahertl)

---

Top Contributors

[![ahertlcode](https://avatars.githubusercontent.com/u/23422837?v=4)](https://github.com/ahertlcode "ahertlcode (17 commits)")[![aoapetu](https://avatars.githubusercontent.com/u/211538907?v=4)](https://github.com/aoapetu "aoapetu (2 commits)")

### Embed Badge

![Health badge](/badges/ahertl-laravel-scaffold/health.svg)

```
[![Health](https://phpackages.com/badges/ahertl-laravel-scaffold/health.svg)](https://phpackages.com/packages/ahertl-laravel-scaffold)
```

###  Alternatives

[bagisto/bagisto

Bagisto Laravel E-Commerce

27.6k172.1k9](/packages/bagisto-bagisto)[unopim/unopim

UnoPim Laravel PIM

10.5k2.4k](/packages/unopim-unopim)[krayin/laravel-crm

Krayin CRM

23.2k33.6k1](/packages/krayin-laravel-crm)[typicms/base

A modular multilingual CMS built with Laravel, enabling developers to manage structured content like pages, news, events, and more.

1.6k20.4k](/packages/typicms-base)[fleetbase/core-api

Core Framework and Resources for Fleetbase API

1235.9k20](/packages/fleetbase-core-api)[tapp/filament-lms

193.4k](/packages/tapp-filament-lms)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
