Move to data-driven decision making with my new NPS survey software.
All my readers receive 10% off for life with code: ian
laravel 4 pre beta primer
November 12, 2012
With the recent release of sneak peek video’s for Laravel 4 there’s been a lot of talk about it lately. It’s still pre-beta and as such there’s very little documentation, but I know a lot of people are excited and would at least like to kick the tires. I’m not an expert myself, but I’ve put together a little quick start guide so you can at least get it installed and be aware of a few important changes from Laravel 3 which should let you build a basic application in just a few minutes.
Note that any and all of this may change! This is written on November 12th, 2012 based on a pre-beta version. Laravel 4 is not currently supported by Taylor or on the forums. Use this at your own risk.
Installing Laravel 4
Laravel 4 now leverages PHP Composer in order to make keeping your application up to date and adding in new functionality a breeze. However, this does change the way we install Laravel. This processes should get you to a working base install.
You now have a basic Laravel 4 app in place.
Laravel 4 Gotcha’s and Changes
There’s a few changes in 4 that might trip up someone coming from V3. Let’s check out a few of the most important ones out.
You no longer use the routing wildcards like (:any). Instead, in your routes name your wildcards and they’ll be processed.
Laravel 4 uses Composer’s auto loading to load up classes you need. It’s setup to statically build a map of class names to file locations for performance. Issues come up when you create a new controller that the auto loader doesn’t know about. To fix that simply run the following command after creating a controller.
Adding functionality via Composer
One of the really great things about Laravel 4 is you can leverage Composer to include new functionality in your application effortlessly. Let’s say we want to add the powerful HTTP client Guzzle to our application. In composer.json, in the root folder, simply add it to the required section:
Then update composer to pull in the library and rebuild your auto load mappings.
You can now use Guzzle directly via its namespace or shortcut it by including the namespace at the top of the files that need it with the ‘use’ keyword.
You can find more great libraries over on Packagist.
Core File Location
The working name of Laravel 4 is Illuminate. I’m honestly not sure if that will remain in place when Laravel 4 is released, but for now you’ll find all the core framework files in
You’ll likely need to do some digging in there from time to time until the docs are ready.
I’m really excited about Laravel 4. Taylor has done a ridiculous job putting this together in such a short time. Laravel 4 isn’t only going to let us PHP developers do things faster, but also make us better programmers. The future is bright for PHP and especially for Laravel.