Laravel Tip: Use generators to create Laravel code quickly. List of generators.

I am taking a little break from writing my “Make a Blog in Laravel” tutorial, i feel like majority of information is already there, just will need some more examples of deployment and what to accomplish next.

Today I will write about how to make deployment of Laravel applications quicker, how to develop with Laravel in an efficient and quick way. Trust me, this can accelerate creation of Laravel applications many-fold! If you feel like you are an accomplished and well-rounded developer, you can skip this stuff, this is not for you. Otherwise, read on!

First, I will share with you what’s the best Programming Text Editor that I’ve ever used and I will suggest you use it too (if you are in process of deciding what to use) since it’s just blazing fast and speeds up development of your web applications.

I use Sublime Text 2 as my default PHP/HTML/CSS/JS editor.

It comes with tons of programmer friendly features such as great syntax highlighting color schemes, file browser, lots of shortcuts, and most exciting (for me, anyway) is ability to create/load snippets that have lots of arguments. For example if you want an “if…then…” statement you would just type “if”, press TAB on the keyboard choose which block of code you’d like and press enter, Sublime Text 2 will automatically insert a block of code according to which language is used, in PHP it will insert :

[sourcecode language="php"]
<?php if (condition): ?>
<?php endif ?>[/sourcecode]

Cool, huh?

There are lots of ready made snippets for Laravel development. I use Dayle Rees’ Sublime Text 2 snippets, you can download them here:

And a Blade Templating engine snippets:

Blade syntax highlight for Sublime Text 2 (requires Package Manager to be installed first):

Also a helpful repository of Bootstrap – oriented Laravel snippets is located here:

For quick code generation there are a few things one could use.

The following tools are a nice addition to Laravel’s Artisan CLI.

Imagine if you wanted to create models, controllers, migrations, tests, bundles just by typing in a command instead of creating each file manually by hand. Well, there are few tools that allow you do that in Laravel.

First, let me introduce Bob. (Everyone says: “Hi Bob!”). Bob wears many hats (literally!)

Bob is a bundle made by Dayle Rees that can help you quickly generate the following things from the command line:

  • Models (and relationships between them)
  • Controllers (files that have a skeleton for your controllers)
  • Tests
  • Migrations
  • Views (including Blade views)
  • Classes
  • Bundles (start.php file inside a directory that will be your bundle)
For example if you would like to create a model “Users” that has many “Posts” you would type in this command in your terminal and it will create the necessary model:
bob model users has_many:post

Easy! Right?

If you have used Ruby on Rails, you will find Bob similar in how to generate files that you need.

You can see lots of example of Bob’s usage on Bob’s personal page here :

Make Bob your friend and your personal assistant in generating Laravel code!

Next up, Jeffrey Way’s Laravel generator.

It is similar to Bob, but it  is more extensive in a few areas, besides controllers, models and views it can generate assets, resources and Migrations with Schema!

There is a nice video of how it is used, I suggest you check it out here:

And the generator itself lives here:

That’s it for today!

I hope these tools speed up your development with Laravel like crazy and hope you have fun using these tools!

Let me know if you have any questions in the comments and follow me on Twitter!