PhpStorm 8.0.3

I recently made the switch to PhpStorm from PhpED and I love it. So let me first say, there’s nothing inherently wrong with PhpEd, it’s a fairly solid editor, and it’s probably capable handling more than I am aware of. We used it at work, so that’s how I ended up using it. But recently, we have changed our development environment, and our team chose PhpStorm.

This turned out to be extremely helpful to me. And a big part of the reason for that is that Laracasts has 23 videos dedicated to PhpStorm. Also, just a side note, these videos are free to watch, so you don’t have to be a subscriber, though I wholeheartedly recommend subscrbing, especially if you are using Laravel.

Another side note, if you are using Yii 2, then check out DoingItEasy on Youtube. These are very helpful videos, especially if you are working through my book Yii 2 For Beginners.

So, getting back to PhpStorm and Laracasts. Until I watched the series of videos, I never really understood the true power of an IDE. And actually, I’m still just learning. But I thought it was important to share some thoughts because I had some unexpected benefits from using PhpStorm.

The first one probably has the biggest impact, which is creating a custom color theme. This doesn’t sound like something significant, but it turned out to be very significant for me.

For one thing, when I made the switch off of PhpEd, I had trouble with the default themes that ship with PhpStorm. Monokai and Darcula, two of the default themes seemed to be the most popular at work, so I tried them. I found the themes to be noisy, with eye-popping colors that interfered with my ability to read the code. It was awful.

I thought I might have to switch back to PhpEd, but that wasn’t really an option, since the team needs to be on the same editor. So I started searching around and I found Dayle Rees’s Color Schemes and reviewed all of those.

While there are a bunch of interesting themes there, I still felt disconnected from them. Another thing compounding the problem is that my eyesight is not that great and it doesn’t take much for me to suffer eye-fatigue. It’s a real problem.

Fortunately, because of Jeffery Way’s videos on Laracasts, I was able to learn how to customize the theme. So I literally spent 5 hours working on a single theme.

I certainly didn’t intend to spend that much time on it. When I looked up at the clock when I was done, I was amazed, because I just pushed through without a break. Crazy. On the other hand, it really paid off because I ended up with a theme that is pleasing to look at and helps me understand my code more quickly. That’s because the color associations are not just pretty, they have intent. The color of methods is related to Classes in just the right way for me, so I can easily understand the relationships. Parameters are distinguished from variables, etc. I found just the right balance of colors that give me hints, but not so much diversity that I can’t untangle the noise.

When I get around to it, I will probably post the settings file on GIT, to share it. But it probably won’t have the same effect for others as it does for me. That’s why customization is so important. You can find the theme most helpful to you by building it yourself. I would highly recommend doing this.

I would write instructions on how to do this, but really, the free videos are the way to go on that one.

Ok, a couple of other high points to mention. The live templates are just super cool. The way it works is you assign a string and action key to a custom template, so with a couple of keystrokes, you can inject a template into your code, a real time-saver.

For example, I use _c followed by pressing the tab key to create a new constructor. It doesn’t seem like much. It’s just a sight gain in efficiency from typing it out, but these slight gains are significant when you scale them out over time.

And of course the longer templates, form fields for example, are just a pleasure to work with. I type in textfield and hit tab and I have a form field waiting for me. You can also pop in the name of the field, and if you have set up the template properly, it will auto-populate the name into all the appropriate places in the form, such as label, fieldname, etc. This saves a lot of typing and time.

Programming time is precious. It’s like gold. Even the tiniest fragments have value. So any efficiency gain you get from your IDE is like putting money in your pocket.

One of the other features that has me really excited is the extract feature, where you can take a block of code and extract it to a separate method. I’m blown away at how well it works. This really helps clean up the code and make it more readable. And it’s so cool to see the choices the editor makes, you can learn from that as well.

PhpEd also has the extract function. Like I said, it’s not a bad editor. What it doesn’t have is 23 videos showing you all the cool things you can do with it.

There are a number of free editors as well, such as Netbeans and Eclipse, so if you are just starting out coding, you might want to try one of these first.

You can also customize your theme in Netbeans, not sure about Eclipse. PhpStorm just seems more robust. The only downside is the cost, but for me it’s worth it because I’m going to be spending a lot of time in my IDE and I need to be as comfortable and as efficient as possible.

A lot of pros also prefer Sublime, but I have no experience with that one, so I can’t really comment on it.

I’ll probably look into Sublime in the future, but for now, I still have a long way to go with PhpStorm for now.

Learning and mastering your IDE, setting up and memorizing all your short-cut keys, templates, color schemes, etc., can take years. But don’t let that intimidate you or cause you to put off learning it. Every little bit helps, even if you start slowly. And if you are like me, you will see dramatic improvements in your work flow as you become more comfortable with it, even when you are new to it like I am.

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…

Yii 2 Para Principiantes Published Today, it’s Yii 2 For Beginners translated into Spanish

I’m happy to announce that Yii 2 Para Principiantes has been published today. This is Yii 2 For Beginners translated into Spanish language by Victor Hugo Garcia.

Victor put a lot of great work into this translation, including translating class names and DB tables into Spanish names when appropriate. The translation covers the core book, up through chapter 11. After that, the bonus chapters are provided in English and will be updated into Spanish as they become available.

Anyone who purchases the book, whether it is the Spanish Version or the English version gets free updates for the life of the book. All you have to do is login and pull down the latest version.

Like its English counterpart, Yii 2 Para Principiantes will take you step by step through setup and installation, and then on to coding in one of the most exciting PHP framework available today. The book focuses on creating a reusable template that can serve as the basis for your projects, including the following features:

      Setup and install
      A Working user model
      User registration and login
      User Profile
      Forgot password recovery
      Frontend and backend separation
      Helper classes
      Access control
      Free/Paid content control
      RBAC with backend UI
      JUI DatePicker
      Facebook Social Widgets
      Font-Awesome Implementation
      Image Upload and Management
      Multiple Social Auth Providers
      Custom Data-driven Carousel Widget
    Facebook Login & Registration with one click

I’d like to give a personal thanks to Victor, who not only gave me a great review on the book at GoodReads.com, but then later also volunteered to write the translation. He put a lot of work into it, so that is greatly appreciated.

Thanks again to all the programmers from around the world who have supported the book, it makes this work possible. I hope you find the book helpful.

Yii 2.0.4 Released

Today marks the release of Yii 2.0.4, which according to the release statement, is a patch release containing over 100 minor new features and bug fixes. I ran composer update on the template that we build in my book, Yii 2 For Beginners, and I’m happy to report that nothing broke, so no modification is necessary this time out.

I recommend updating to version 2.0.4. Like I said, it’s simple, just run composer update from the command line and you will get the latest version that will bring you up-to-date.

In other news, we have a Spanish translation of Yii 2 For Beginners being released soon, so that is very exciting. Victor Hugo Garcia is doing the translation and we’re looking forward helping Spanish-speaking programmers get started with Yii 2.

Learning a PHP framework can be a daunting task. I know this because it was difficult for me, and that inspired me to write the book. I’ve come to understand that learning a framework, much like learning programming itself, is a journey, not a destination.

Many times I thought of learning PHP in terms of one framework vs. another, and in some ways, that is what kicked off this blog back in March of 2014. However, my view on this has evolved.

I think it’s important to learn multiple frameworks. It will allow you to see programming from different angles, different approaches, and you will learn from all of them. Then you can decide which one is best for you, or even better, you can gain proficiency in multiple frameworks. This gives you more value to potential clients that might want you to do a project in a framework other than the one you prefer.

The programmers that build and support these frameworks, Yii 2, Laravel, Symfony 2 and others, bring an amazing amount of innovation, talent and infrastructure to support your growth as a programmer. As I mature as a programmer, I have come to value all of them for the contributions they have made to PHP programming. Where would we be without them?

So today, being a release day for Yii 2.0.4, I will thank the Yii team once again for all the amazing work that they do.