Laravel 5.1 is released

Laravel has just announced the immediate availability of v5.1. This marks the first release in Laravel’s history to offer long-time support. Let’s look at some of the new features and also learn more about it directly from Taylor Otwell.

Long Term Support

Since originally launching in 2011, Laravel has always followed the “release early, release often” mantra which is popular in open source applications. With the historic rise in popularity of the framework, it was time to start focusing on the needs of large organizations and mission-critical applications that need security fixes but can’t upgrade quickly. Laravel 5.1 will now include 3 years of security fixes.

The long-term support is arguably the biggest feature in 5.1, but it includes several other new features.

New Documentation

The documentation has been completely reworked to offer more clarity, to be more in-depth, and to have a nicer flow. This was a huge undertaking and countless hours was spent fine-tuning each page.

Taylor said he would delay an entire Laravel release rather than release something with poor documentation, when asked if spending this much time on it was worth it. Another new documentation feature is real-time search with auto-complete.

PSR-2

The app and generators have been converted to PSR-2. The biggest change from current Laravel style is tabs to spaces and control structures will now go on the same line.

Resolve a service from blade

You can now resolve a service directly from a Blade Template:

@extends('layouts.app') @inject('stats', 'StatisticsService') <div>{{ $stats->getCustomerCount() }}</div>

Broadcasting Events

Laravel already included a powerful event system and this new feature builds on that by allowing you to broadcast events over a websocket so your client can consume them. With this new feature, it makes creating real-time applications simple.

Better Application Unit Testing

With an inclusion of Laracast’s integrated testing package testing your application is going to be easier than ever before.

public function testNewUserRegistration() { $this->visit('/register') ->type('Taylor', 'name') ->check('terms') ->press('Register') ->seePageIs('/dashboard'); }

For an in-depth look at these features, plus more, take a look at the Laracasts video series and Matt Stauffer is creating written tutorials.

***

Q&A with Taylor Otwell

I had a chance to sit down with Taylor Otwell and ask him about this release and what it means for us Laravel developers:

One of the biggest changes in 5.1 is this will be Laravel’s first LTS version. Can you tell us how that’s going to work?

This is the very first LTS (long term support) release for Laravel. This means that that Laravel 5.1 will receive 2 years of bug fixes and 3 years of security fixes. LTS releases will be released every 2 years, meaning the next LTS release will be in May of 2017. Laravel releases with long term support provide more peace of mind to development shops or clients that need assurance of continued bug fixes for several years.

You’ve spent a tremendous amount of time on rewriting the entire documentation. Do you think this will help drive Laravel adoption?

Good documentation is one of the most crucial aspects of any open-source project. Yet, it’s so often neglected or delayed until after release. If I could give project maintainers a single piece of advice, it would be to never release anything that isn’t well documented. I would delay an entire Laravel release rather than release something with poor documentation. I think the improved documentation will drive even more adoption of Laravel. Of course, I always have tricks up my sleeve and I have even more to announce in this space soon. Continuing to make Laravel enjoyable to learn is one of my biggest passions.

Out of all the new features which one are you most proud of and which one do you think is the most important?

Honestly, I think the documentation is the “feature” of Laravel 5.1 I’m most proud of. It’s just so much better. As far as technical features go, I love event broadcasting. It didn’t take much code to implement, but it’s just so convenient to use and makes it simpler to get started building real-time applications. Middleware parameters are another great addition to Laravel 5.1, and were actually implemented by a community member. Again, that’s a feature that did not take much code to implement but will make a lot of users very happy.

Laravel 5.1 also introduces PSR-2. A lot of people have complained this should have been done sooner. What are your thoughts on that?

It’s very hard to introduce a new coding style in a project with a lot of contribution activity. Before I started working full-time on Laravel, it was routine for there to be several hundred open pull requests. Converting the entire project to PSR-2 at that time would have meant rebasing every single open pull request. Now that I work full-time on the project, there may only be 20-30 open pull requests at a time across the entire Laravel GitHub organization, which is much easier to manage. So, this is the perfect opportunity to adopt PSR-2, and I’m already loving being able to run a simple Sublime Text build command to format all of my code.

Are you still staying true to your original goals when you first created Laravel?

Out of all of the Laravel releases, I think Laravel 5.1 is my favorite. It streamlines and improves much of what was introduced in Laravel 5.0. Firstly, I think it makes the folder structure more “human friendly” by renaming “Commands” to “Jobs”, and moves away from the complicated “Handlers” directory structure to a simple, single “Listeners” directory for event listeners. Event broadcasting is a classic Laravel feature. To broadcast your events over Pusher or Redis you simply add a “ShouldBroadcast” interface to your event class. That’s it. I love small features that are simple and elegant. Middleware parameters improves the original middleware introduced in 5.0 and makes them just as powerful as the Laravel 4.x route “filters”.

I’m sure with the umbrella of Laravel products it takes a lot of your time, but now that 5.1 is out, what are you plans for the rest of the year?

My immediate plans are to improve a few Forge features. I would like to bake-in AWS support as well as improve the environment variable management to make it more like Envoyer’s. I’m also working on a few things to make Laravel even easier to learn.

***

Where to go next

Head over to the new official documentation which includes everything you need to know about installation, upgrading, and all the framework features.

Of course subscribe to the Laravel News weekly newsletter to stay up to date with all the new tips, tutorials, and news about the framework.