way/generators
Way Generators is a Laravel scaffolding package that speeds up development with Artisan commands for creating migrations, models, controllers, seeders, and more. Customize the stubs to match your conventions and skip repetitive boilerplate.
way/generators is Jeffrey Way's Laravel 4 generator suite — the direct ancestor of Laravel 5's built-in make:* commands. It turns "write the migration, model, controller, views, seed and test for a new resource" from a 20-minute chore into a single Artisan call. It is Laravel 4 only; do not install it on 5+ alongside the core generators.
Install (Laravel 4.2 app):
composer require way/generators:~2.0 --dev
# Laravel 4.0/4.1: use the corresponding 1.x tag or dev-master
Register the provider in app/config/app.php:
'Way\Generators\GeneratorsServiceProvider',
Optionally publish config so you can move output paths:
php artisan config:publish way/generators
php artisan list | grep generate # sanity check: commands are registered
First use case. Greenfield CRUD, one command:
php artisan generate:scaffold Post \
--fields="title:string, slug:string:unique, body:text, published:boolean, user_id:integer:unsigned"
That produces a migration, model, resourceful controller, Blade views in app/views/posts, a seed, a test and (in 2.x) a form partial. Then:
composer dump-autoload
php artisan migrate
# routes.php
Route::resource('posts', 'PostsController');
If you want a lighter footprint than scaffold, generate:resource covers the model/controller/views/migration core, and the individual generate:* commands let you add one piece at a time.
The --fields mini-language is the core skill. Field modifiers are colon-chained and consumed by the migration compiler:
name:string
name:string:unique
user_id:integer:unsigned:index
body:text:nullable
Keep the same string handy — it is the contract between migration, model $fillable, form partial and views. Store it in a project note or a scaffold.sh script so re-generating a resource is reproducible.
The command ladder. Use generate:scaffold for the first pass of a brand-new table; use the narrow commands for everything afterwards:
php artisan generate:migration add_slug_to_posts_table --fields="slug:string:unique"
php artisan generate:model Post --fields="title:string, body:text"
php artisan generate:controller Admin/PostsController --resource
php artisan generate:view posts.show --fields="title:string, body:text"
php artisan generate:form posts # reusable Blade form partial
php artisan generate:seed posts
php artisan generate:test posts
php artisan generate:pivot users roles # join table migration for an M2M
generate:pivot is the biggest time-saver you'll miss elsewhere — it derives the singularised join table and the two foreign-key columns from the two table names.
Integration flow that matches how Laravel 4 apps actually get built:
generate:migration → adjust column types/constraints → php artisan migrate immediately, before writing application code.generate:model → add relationships and accessors.generate:controller --resource → replace the placeholder bodies with real queries and validation.generate:view (or scaffold) → rewrite the markup to your design; the generated Blade is a starting point, not a deliverable.composer dump-autoload — mandatory, see gotchas.Custom templates for house style. The generator templates live in the package's templates/ directory and are located through the published config. Copy the ones you care about into your app, edit them to match your conventions (bootstrap version, layout name, repository pattern, base controller name), point the config's template path at your copies, and select them per invocation with --template. This is how you make scaffolded output merge-ready instead of something reviewers reject.
Path overrides. Most commands accept --path (and --bench inside a workbench package) so you can target a module/package directory instead of the default app/* locations — useful if you keep models under app/modules/blog/models rather than app/models.
Extension points. Commands are resolved from the container by GeneratorsServiceProvider, and field parsing is isolated in Way\Generators\Parsers\*. If your team needs a new modifier (say :encrypted) or a new generator, subclass the command/parser and register your binding in your own service provider.
make:* commands; installing this alongside them gives you duplicate/conflicting command names and a broken Artisan boot.composer dump-autoload after every generation. Laravel 4 autoloads app/models, app/controllers, app/database/seeds and app/tests via Composer classmap, not PSR-4. A freshly generated Post class does not exist until you dump — this is the #1 "the generator is broken" false alarm.Form:: / HTML:: dependency. Scaffolded views and form partials emit Form::open(), Form::text(). Laravel 4 ships those in illuminate/html (later laravelcollective/html); install it and alias 'Form' => 'Illuminate\Html\FormFacade' or the generated views fatal with "Class 'Form' not found".git diff.Y_m_d_His-based; two migrations generated in the same second can collide/overwrite. Generate one table at a time and ls app/database/migrations afterwards.create_posts_table for new tables and add_x_to_posts_table for changes. Table names and Schema::create vs Schema::table are inferred from the migration filename — unusual names produce a stub you must hand-fix.--fields. Use double quotes, no spaces after commas, and escape $ if a default value contains one. A silently truncated field string is a common cause of "why is my migration missing columns".$fillable from --fields — if not, add it immediately or mass assignment will silently drop fields.app/models, app/views, app/controllers, controller extending BaseController). Repositories, namespaced controllers or view namespaces mean editing generated files, or better, customising templates/config first.-v to see resolved output paths and the exact file the generator tried to write; run php artisan generate:<cmd> --help to confirm which options (e.g. --no-timestamps, --soft-deletes, --template, --path) exist in your pinned version — they shifted between 1.x and 2.x.How can I help you explore Laravel packages today?