What’s new in Laravel 4

I created this presentation for a Laravel Meetup that I organized.

It explains what’s changed in Laravel v4 over v3 and brings up some nice examples of using new features.

Check it out :

And the transcript of it is below:

laravel 4

What’s old?
What’s new?

by Maks


  • Clean and Eloquent syntax.
  • Separation of elements
  • Awesome community
  • Joy to code with
  • Same Creator and visionary – Taylor
  • Still PHP, but better (like traits in PHP 5.4)


  • Command line is a lot more powerful
  • Testability (all components Unit Tested)
  • Mail component built in
  • Packages instead of Bundles (7000 vs 200)
  • PHP >= 5.3.7 
  • Resourceful routes + controllers
  • PSR-0 camelCase instead of snake_case

Command line magic

php artisan controller:make PhotoController

Produces RESTful controller:


class PhotoController extends BaseController {
	public function index(){}
	public function create(){}
	public function store(){}
	public function show($id){}
	public function edit($id){}
	public function update($id){}
	public function destroy($id){}

In Routes.php :

Route::resource('photo', 'PhotoController');

Command Line Magic

Actions handled by Resource controller:

Verb Path Action 

 GET /resource                                               index 

 GET /resource/create                               create 

 POST /resource                                            store 

 GET /resource/{id}                                      show 

 GET /resource/{id}/edit                           edit 

 PUT/PATCH /resource/{id}                   update 

 DELETE /resource/{id}                             destroy

More Artisan commands

php artisan list to see all
db seed
workbench – creating new packages

Make your own commands

php artisan command:make FooCommand

Testing and TDD

Support for PHPUnit out of the box
Example of a test:
$response = $this->call('GET', 'user/profile');

DOM crawler:

$this->assertCount(1, $crawler->filter('h1:contains("Hello World!")'));

Packages : 

  • MongoDB
  • LessPHP
  • Bootstrapper
  • Former
  • Coffee – coffescript compiler
  • Flatten
  • 6994 more packages.


Easy email with Swiftmailer built in.
Mail::send('emails.welcome', $data, function($m)
	$m->to('maks@example.com', 'Maks')->subject('Welcome!');


Gone : STR:: and HTML:: helpers

Find replacements as Composer Packages:

Different Routing

Route::get('user/{name?}', function($name = 'John')
    return $name;

Route::get('user/{name}', function($name)
->where('name', '[A-Za-z]+');

Route::get('user/{id}', function($id)
->where('id', '[0-9]+');

Sub domain Routing

Route::group(array('domain' => '{account}.myapp.com'), function()
    Route::get('user/{id}', function($account, $id)

Route prefixing

Route::group(array('prefix' => 'admin'), function()
    Route::get('user', function()


Liked it? Take a second to support Maks Surguy on Patreon!
Become a patron at Patreon!

You may also like

One comment

  • vaqasuddin March 19, 2013  

    Well its looking nice than the previous obviously previous version was great but this one is too much extra best !

    Hats off !

Leave a comment