Tag Archives: laravel 5.1

Laraboot: Laravel 5* For Beginners Now Available

I’m happy to announce the release of Laraboot: Laravel 5* For Beginners today. The base book comes in at 370 pages and covers everything you need to know to get started in Laravel. And there is more coming as I release the bonus material over the next 30 days or so.

I’ve kept the minimum price of the book low because it just launched and I want to give everyone who purchased Yii 2 For beginners a chance to get it at the lower price. Once the page count swells, I will normalize the price.

I’m also happy to announce that you can purchase both books, Laraboot: Laravel 5* For Beginners and Yii 2 for Beginners in a single Bundle named PHP Frameworks Laravel 5* & Yii 2. That’s over 1000 pages of material and working code.

I’m really committed to helping PHP programmers become familiar with these frameworks, so they can increase their earnings potential. Both frameworks are great frameworks to learn and you really can’t go wrong by learning them.

This time out, I branded the re-usable template with the name of Laraboot. Everything in Laravel seems to be branded, so I jumped on board with that. I take a lot of pride in how clean and simple the code is in Laraboot. I think you will appreciate how easy it is to learn and use.

A word of thanks to all the programmers from around the world who have supported my writing with positive comments, reviews, and referrals. Yii 2 For Beginners got 4.67 out of 5 stars on Goodreads.com. I’m hoping to do even better with the new book. It really does inspire me to work harder, knowing that the work matters and that people appreciate it, so thanks again!

Advertisements

Laravel 5.1 Released

Laravel 5.1 is released today and it’s awesome. While there are only a few differences between 5 and 5.1, they are impactful, and really cement Laravel’s position as an enterprise framework. One of the most obvious changes is LTS, long term support, which fixes bugs (2 years) and security patches (3 years). This is obviously critical to enterprise development.

Another leap forward is the quality of the documentation. It’s incredible. Taylor Otwell wrote the documentation himself, and put the same obsessive care into the docs as he does the framework itself. This attention to detail really shows.

The first huge feature of the docs is the search window.  It’s easy to overlook, since I’m not used to using it and there is no label, but this is powerful.  It autocompletes what you are looking for and even does a good job of guessing on typos.  For example, when I typed in redur, it correctly understood I was looking for redirect.

Type in something like val and select validation.   Look at how great the Validation docs are. In the validation quickstart section, he begins with a route definition and takes you all the way through form validation, so it’s clear and comprehensive. We learn for example that all validation errors are automatically flashed to the session and are always available in the view through an $errors variable. Then of course we get a comprehensive list of validators.

If your validation requires a dependency, there is a great example, using the sometimes method to show you how to do it under the complex conditional validation section.

Another example of how thorough the documentation is the section on migrations. It’s a complete reference to:

      Creating Tables
      Renaming / Dropping Tables
      Creating Columns
      Modifying Columns
      Dropping Columns
      Creating Indexes
      Dropping Indexes
      Foreign Key Constraints

In the past I never really liked migrations, but I have come to appreciate them, especially since the workflow and execution on Laravel is so good.

The validation and migration sections are typical of the quality of the docs, I pretty much chose them at random.

Not only do great docs make it easier for beginners to find what they need, but obviously, they are a must have for enterprise development. Great documentation leads to coder happiness. Happy coders are productive coders. Productivity is essential for a successful enterprise.

Another change in 5.1 is the move to PSR-2 coding style, which is the one I’m most familiar with, so no complaints here.

Laravel 5.1 also introduces parameters on the middleware. If you are unfamiliar with the middleware class, it replaces the filters from previous versions of laravel. At first, I found this part of the structure a little complicated, but I have grown to appreciate it.

Basically middleware is a series of filters that are injected into requests via route definition or controller. They are super simple and easy to use, once you understand it, and once you see how it fits into the application structure. Not only that, but Laravel 5.1, like 5.0, has code generators for these specific classes via artisan, which will place them into the appropriate folders for you. So this helps you deal with the folder structure more easily.

While it’s true that new folder structures of 5/5.1 are way more complicated than what I was previously used to, they have had a curious side-effect. It’s actually easier for me to conceptualize or visualize the application as a whole. The discreet parts of the application make more sense to me. In the long run, the complicated folder structure makes application development easier and cleaner. You get far fewer overstuffed classes in favor of a greater number of leaner, more focused classes. It makes for cleaner code.

The release of 5.1 also includes the new @inject method for blade, which allows you to bring in a class instance from a service provider or helper class directly into your views. Normally, you would bring in all of your object variables into the view via the controller, but this could lead to code duplication. So, as in the latest example from Laracasts, if you have a stats object that you wish to use in many views, you can simply access it directly from within the view via @inject. This helps make code re-use simpler, since you don’t have to bind a view composer to a route.

Since I mentioned Laracasts, they have a bunch of new videos released today for 5.1, all worth checking out. Everyone here at work loves Laracasts.

The last new features that I’ll talk about in 5.1 are the model factories for seeding and the enhanced test integration. Model factories help automate the data seeding process, a very handy feature. It was already fairly easy to seed data and this just takes it a step further.

I’m going to defer to the testing video at Laracasts for the new testing improvements explanation, but I will say that it’s got the developers here excited about how easy it will be to test forms. It’s a huge plus.

For more info about the release, check out the Laravel 5.1 release notes.

Ok, so to wrap it up, let’s offer congratulations to Taylor Otwell and the rest of the Laravel team for releasing such a great enterprise framework. It’s through the work of teams like this that innovation and success becomes more accessible to all of us. It is much appreciated.

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 GoodReads.com.

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…