03.12.2015 Views

laravel4cookbook

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

API 113<br />

1 php artisan controller:make EventController<br />

New migrations can also be created with the command:<br />

1 php artisan migrate:make CreateEventTable<br />

These are neat shortcuts but they’re a little limited considering our workflow. What would make<br />

us even more efficient is if we had a way to also generate models and seeders. Enter Jeffrey Way’s<br />

Laravel 4 Generators…<br />

.<br />

You can learn more about Laravel 4’s built-in commands by running php artisan in your console,<br />

or at: http://laravel.com/docs.<br />

Creating Resources With Generators<br />

With the generate methods installed; we can now generate controllers, migrations, seeders and<br />

models.<br />

Generating Migrations<br />

Let’s begin with the migrations:<br />

1 php artisan generate:migration create_event_table<br />

This simple command will generate the following migration code:<br />

1

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!