It’s Laravel 5.1 for Enterprise Development

That’s a heck of a headline for a guy who wrote a book on Yii 2, certainly not where I expected to be at this point in time. When I first reviewed Laravel 5, I had an allergic reaction to it and wrote a snarky review on Laravel 5.0 (which I’ve since removed). So how did I go from that to recommending it for enterprise development?

Well, this transition started a few months ago, with the programmers in my company expressing a desire to move to Laravel. My first impulse was to say, “no way.” I had just spent a year preparing for our move into Yii 2. I fell in love with Yii 2 and wrote a 691 page book about it for beginners. I took a lot of pride in the book and kept working on it to make sure all the code worked and was clear and easy to understand. I got great feedback from the readers and have a 4.59 out of 5 rating on

So obviously it was a bit of shock to hear about laravel from the team. But rather than take a top down approach and dictate the framework choice, I wisely chose to open the topic to discussion and evaluation from programmers who are more advanced than I am. To keep up, I had to dig in deep and see if I could find what I felt I was missing. And the deeper I went, the more things started to tilt towards laravel.

To get there, though, I had to overcome my initial bias against Laravel, which based on the fact that Laravel was built on Symfony components, used Doctrine, and seemed to hardwire migrations into the workflow, at least in all the examples they were providing. So my objection was that it was slower, bloated, and not as database centric as I preferred.

In working with Laravel, however, I found that it wasn’t noticeably slower and the use of migrations led to a good work-flow, that if used correctly, could still adhere to proper discipline concerning the DB. Plus PHP 7 is on the horizon and it looks like it will eliminate most of the framework overhead, so the concern over using a framework that utilizes other big components like Symfony and Doctrine is no longer a significant factor.

Another thing that always threw me off with laravel was the obsession with the use of dependency injection. That never really clicked with me in the past, I just could never put all the pieces together to make sense of that. It somehow seemed gratuitous.

To put a little perspective on that, I always viewed coding to a contract as a more expensive proposition without a lot of upside. I thought it was an approach that was too intellectual, not practical, a better fit for java than for PHP.

I was 100% wrong about that. 100%. Wrong. Painfully so.

Anyway, the changes in laravel 5.0 and 5.1 really brought this to light. For example, their request class, combined with method injection is a very beautiful way of handling validation.

If a class is namespaced properly, you can inject an instance into either a constructor or method signature, without having to otherwise instantiate it, a nice piece of magic accomplished by reflection.

But even better than that, the service providers allow you to bind a concrete class to a contract, so you can call the instance of the class via the contract.

This makes changing the implementation of a class everywhere in your code as simple as changing one line of code. It’s awesome. That means you can test different implementations without having to create separate branches of your project, which makes it easier to manage.

One of the big features of laravel, one that moved our team sharply in their direction, is the ease of frontend integration using blade. It’s a super-clean template engine with crystal clear syntax. It makes working with bootstrap and jquery a snap. It also makes working with interspersed html and php very easy and clean.

There’s an old saying that fortune favors the bold. It may be a cliche, but it’s true. Taylor Otwell had a bold vision for laravel going back a number of years. In his book from 2013, he talked about changing the concept of model, long before laravel 5.1 came to fruition. And in some ways, it’s a counter-intuitive move, at least in the sense of moving things towards simplicity.

In a general sense, Occam’s Razor states that simplest answer is typically the most efficient. And I’ve always found that this is a great way to approach life, business and coding. But sometimes that can cause too narrow of a vision.

This is where Taylor boldly stepped forward. Fragmenting the idea of a model into smaller components is more complicated, but results in a more efficient workflow and maximizes the gains from loose coupling. While I can’t visualize the directory tree as easily, I feel more connected to the concepts, they seem clearer.

And while the structure is more complicated, the code generation via artisan takes this into account and helps you stub out handlers, service providers, middleware, and other class types, namespacing them for you and placing them in the proper folders in the application.

I don’t know how it is for other programmers, but I find most of the laravel syntax incredibly intuitive, and more so over time. This is not an accident. It’s all part of a cohesive set of principles and design patterns that are playing out perfectly at scale. It’s proof that the SOLID principles, and taylor’s specific implementation of them, actually matter.

So this was a huge attraction for our team, a sense of commitment from the path Taylor is blazing, that if we followed it, we would become better programmers. You know you have a future in programming if that idea excites you.

The title of this post is It’s Laravel 5.1 for Enterprise. One of the reasons for this is that Taylor has developed an entire suite of products designed to support enterprise development. These include, laravel(PHP framework), forge (server management), lumin(PHP micro-framework), homestead(local dev environment), laracasts(video tutorials), elixir (asset management), artisan (command line interface), and I’m sure I’m probably forgetting something. Oh yeah, envoyer, which gives you seamless deployment with no downtime.

The point is that laravel itself is run like a commercial venture, and this is a big plus for enterprise development. With 5.1, they have also announced long term support. So that means we can count on bug fixes and security patches for years to come.

And so now this brings us to laracasts. The story of the rise of laravel would not be complete without mentioning Jeffery Way and laracasts. Taylor is lucky to have him on his team, he is a world-class instructor, helping all of us stay on the forward edge.

While I could write an entire post about the great quality of laracasts and how useful the videos are, the really short version for now is that our company purchased a company license, so that all our programmers can have access to the videos on demand. The videos are that good. To borrow from another cliche, the videos contribute to programmer happiness, which is vital to the success of the company.

So this all worked out perfectly for my company, the programmers are happy with the decision to use laravel for our future development. But where does this leave me and this blog? Obviously this post is not going to boost book sales, at least not mine.

Well, I still love Yii 2. It’s a great framework and it taught me a lot about programming. I still recommend learning more than one PHP framework and Yii 2 is an excellent choice. I’m still proud of the book I wrote for it.

At the same time, I feel a sense of loyalty to everyone who bought the book and to the readers of this blog. Rather than simply just stay silent, I thought it was important to share my views and our company’s conclusions regarding framework choice.

Going forward, I’m going to be coding in laravel. That means at 691 pages and a translation into Spanish, my Yii 2 book is complete. It’s been a great experience, but it’s time now for me to move on to a new chapter in my coding journey…


20 thoughts on “It’s Laravel 5.1 for Enterprise Development”

    1. Martin, thanks for your interest. I don’t know at this point. I’m going to continue to share development tips for now and we’ll see how it goes.

  1. I started with Yii and then adopted Yii2 when it was released…at the same time I kept an eye on Laravel and I have to confess that I was having the same thoughts as the developers in your company: Laravel seems to offer better learning resources (Laracasts) and a more enterprise-like framework. Furthermore, it looks like you can learn a lot of design principles from the framework (I do not have the same feeling when using other frameworks, including Yii2)

  2. I forgot to mention that I bought your book as a way of starting learning Yii2, and I enjoyed it very much. Keep up the good work with Yii2 as much as you can…one of the reasons why I started learning Yii was because Larry Ullman was writing a book about it. Then I found your book as a complementary resource. In general, I think that Yii2 is an excellent framework…but overall I think that Laravel has the lead. In particular, Laracasts are just awsome…I don’t think that Yii2 nor any other framework can beat Laravel in the short term. As for me, I would really like PHP to have a dominant framework (in the same way as Ruby has Rails or Python has Django), and it seems that Laravel can very well become such a framework.

  3. I started out with Laravel 4 as my first foray into PHP frameworks. I’m not a programmer – not since University at least, so I did a lot of research to decide on Laravel. I made an app after a few weeks and I was reasonably happy with the results. However, I am now switching to Yii2 for two reasons – Gii and widgets. Gii just saves so much time as I wrote all the forms and CRUD manually in Laravel. Widgets will same so much time as well since I have no plans to learn JavaScript and again, it will get me from point A to point B much faster. Now that I am starting to learn Yii2 I can appreciate Laravel’s more intuitive nature. In terms of learning and tutorials, Laravel was much easier to grasp. Regardless the amount of time Gii and widgets will save me will be worth it IMO.

    -signed… a lowly casual programmer

  4. big thumbs up. Love this honest and self reflecting post. You would have big reason to not say this (as you make money with your book), but writh this so honest. big respect, if all people were like this, we would live in a much better world.

  5. I am a experienced programmer . I have built two mini-erp systems for my institution on Yii1 and Yii 2. I contributed on a few yii2 extensions on github. I dont have problems with documentations. Once you realize how Yii2 works ,its faster than anything on the WEB, including RoR and any java full stack or partial framework. I can create gii templates to use my prefered kartik widgets. I dont need to touch one single line of Css/javascript. EVERYTHING is PhP !!!! there is no other syntax needed!!

  6. I’ve had experience on Yii1 and currently developing on lumen framework (on Laravel components 5.2). The more I learn about lumen, the more I get surprised why Laravel is the most popular framework. I have to add that it’s mostly used in US. Dear author do you have any technical/programatic reasoning behind your decision on selecting Laravel over Yii2? How many times have you used Laracasts? (I asked 7 questions there, 6 of them without any single response) How many times have you used Yii forums? How many experienced Laravel developers you know that do real contribution to this framework?
    Laravel is resource hungry, but PHP7 compensates this issue! I don’t buy it. Laravel is way off behind Yii2!
    By the by, I’m sorry for my acrimonious remarks.

      1. Thanks for your kind comment Bill. I just took a cursory look to your article. Although the main idea is how cool Laravel is, but if I want to compare it against Yii I have to say:
        1. Commitment to Excellence: It does not like a reason to an engineer
        2. Constant Evolution & Growth: Totally agree. Yii took it so long to release version 2 (It was a total rewrite of Yii1, but it does not mitigate community eagerness)
        3. Documentation: Lack of examples, like many other frameworks. Basic examples are not the case!
        4. Elixir: I have not used it at all
        5. Out-Of-The-Box Authentication: Yii1 had this feature many years ago!
        6. Artisan & Code Generation: A white elephant! ‘php artisan make:carrot’ there you go ‘class YourClass extends Carrot {}’ And that’s it. I bet you know how powerful Yii Gii tool is.
        7. Plays Well With Others: Agree completely. The whole service container idea is a blessing for a developer!
        8. Eloquent: And again Yii1 Active Record had it all.
        9. Official Packages & Extensive Ecosystem: That’s one of the weaknesses of Laravel. Using composer and passing the buck to other packages. No native MongoDB Support, Localization is a mess. Yii integrity and official support is amazing.
        10. Jeffery Way & Laracasts: Unfortunately I have not used these videos.

      2. The only way you are going to really know the difference is to use both frameworks and decide for yourself, this is what I have done. When I was an absolute beginner, I tended to agree with you and the arguments you are making sound like the things I used to say. That was before I did a deep dive into Laravel. If you don’t feel a commitment to excellence is a valid reason to use a framework, that is your choice, others may disagree. Artisan provides a wider range of class types, without all the useless code that has to be overwritten. Anyway, there is wide consensus among developers that Laravel is the most popular framework:

        There are reasons for this. My article gave you my reasons. Cheers.

  7. If you like rewriting half your application every roughly 5 month then Laravel is certainly for you, with the horrendous backwards breaks and no clear strategy for the future.
    I personally like to do the work once and move on.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s