Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Generators Laravel Package

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.

View on GitHub
Deep Wiki
Context7

Getting Started

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.

Implementation Patterns

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:

  1. generate:migration → adjust column types/constraints → php artisan migrate immediately, before writing application code.
  2. generate:model → add relationships and accessors.
  3. generate:controller --resource → replace the placeholder bodies with real queries and validation.
  4. generate:view (or scaffold) → rewrite the markup to your design; the generated Blade is a starting point, not a deliverable.
  5. 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.

Gotchas and Tips

  • Abandoned and version-locked. Last release October 2014, MIT, effectively a historical artifact. On Laravel 5+ use the core make:* commands; installing this alongside them gives you duplicate/conflicting command names and a broken Artisan boot.
  • PHP era mismatch. Written for PHP 5.3/5.4. On PHP 7.1+ you'll hit deprecation noise or outright fatals in the reflection/template code. Run it on a PHP 5.x toolchain (VM, Docker) if you must keep a legacy app building.
  • 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".
  • Generation overwrites. The commands write files without a meaningful interactive guard. Scaffolding over an edited controller loses the edits. Commit or stash before a scaffold run and review git diff.
  • Migration timestamp collisions. Filenames are 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.
  • Naming drives the stub. Use 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.
  • Shell quoting of --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".
  • You get structure, not behaviour. Generated controllers have no validation, no authorization, no eager loading; models have empty relationships. Budget the follow-up pass, and check whether your version pre-populates $fillable from --fields — if not, add it immediately or mass assignment will silently drop fields.
  • Path defaults assume the vanilla skeleton (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.
  • Debugging. Re-run with -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.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
jinas/dhivatar
store-doc/laravel-storage-driver
plus-it/laravel-translation-manager
diephp/perhaps
diephp/telegraph
osmaviation/spreadsheet
microsoft/fluentui-system-icons
mmccook/php-json-canonicalization-scheme
middlewares/firewall
qubiqx/montapacking
nyoncode/laravel-package-console
pnscripts/filament-broadquill-lite
pnscripts/laravel-sentfold-lite
vleap/mx-sdk-laravel-internal
twidpay/utils
htetmyathlaing/scout-elasticsearch-driver
artisan-toolbox/front-awesome
ls/client-assistant
users-au/laravel-client
cgv/localized-resource