neuron-php/scaffolding

Code generators and scaffolding tools for Neuron framework

Maintainers

Package info

github.com/Neuron-PHP/scaffolding

pkg:composer/neuron-php/scaffolding

Statistics

Installs: 921

Dependents: 2

Suggesters: 0

Stars: 0

Open Issues: 0

0.8.10 2026-06-05 15:57 UTC

This package is auto-updated.

Last update: 2026-06-05 15:58:53 UTC


README

CI codecov

Neuron Scaffolding

Code generators and scaffolding tools for the Neuron PHP framework.

Installation

composer require --dev neuron-php/scaffolding

Available Commands

CRUD Resource Generation

Generate a complete, runnable Neuron ORM CRUD stack — model, DTO YAML, repository (interface + database implementation), an attribute-routed controller, and field-aware views — with a single command.

# From an explicit field spec (creates a new table + migration)
php neuron scaffold:generate Post \
  --fields="title:string,body:text,published:boolean"

# From an existing database table (introspects columns; skips migration)
php neuron scaffold:generate Docket --from-table=jud_docket

The --from-table path introspects the live schema via PDO (information_schema.columns on MySQL/PostgreSQL, PRAGMA table_info on SQLite) using the project's configured connection, so it is the primary path for mapping existing GroupOffice tables.

Wide tables: exposing a subset

Large legacy tables (e.g. jud_docket) often have many columns you don't want in the editing UI. Inspect the columns first, then narrow the editable surface with --only or --except:

# 1. See what's there (prints columns + types, generates nothing)
php neuron scaffold:generate Docket --from-table=jud_docket --list-fields

# 2. Expose just the columns you need
php neuron scaffold:generate Docket --from-table=jud_docket \
  --only="case_number,status,filed_date,judge_id"

# ...or keep everything except a few
php neuron scaffold:generate Docket --from-table=jud_docket \
  --except="created_by,modified_by,acl_id"

--only / --except affect only the DTO and views — the model, repository, and migration always map the complete table, so inserts and updates that touch NOT NULL columns keep working. The primary key is always retained. (--only and --except are mutually exclusive.)

Generated controllers use PHP 8 route attributes (#[Get] / #[Post] …) — no routes.yaml is written. Unsafe-method routes are tagged with filters: ['csrf'], and forms emit csrf_field(); both are provided by the framework-level CSRF support in neuron-php/mvc (enabled by default via the security.csrf setting), so no per-app wiring is required.

After generation, bind the repository interface to its database implementation in your service provider, e.g. IPostRepositoryDatabasePostRepository.

Controller Generation

php neuron controller:generate UserController --type=resource

Event & Listener Generation

php neuron event:generate UserRegistered --property="userId:int" --property="email:string"
php neuron listener:generate SendWelcomeEmail --event="App\Events\UserRegistered"

Job Generation

php neuron job:generate SendEmailReminders --cron="0 9 * * *"

Initializer Generation

php neuron initializer:generate QueueInitializer

Migration Generation

php neuron db:migration:generate CreateUsersTable

Email Template Generation

php neuron mail:generate welcome

Learn More

Visit neuronphp.com for full documentation.