Yii 2.0.6 Released

On August 5, 2015, Yii 2.0.6 was released. You can check out the official release announcement here.

This release has over 70 minor new features and bug fixes, including:

  • better migrations syntax
  • improvements in error handling
  • more control over ActiveForm using javascript
  • nested Yii::t() calls
  • extra session fields

I’ve looked over the changes and I don’t see anything that would conflict with the code in Yii 2 For Beginners.

Initially, when I tried to upgrade to Yii 2.0.6, I had problems and got an error:



  [UnexpectedValueException]
  Could not parse version constraint <=2.*: Invalid version string "2.*"

So I put in a request to the friendly forum and got the response I needed:

to fix this, do



composer global update #this will update the fxp which causes your constraint issue
composer update  

Once I did that, everything updated perfectly. I have not found any problems with my template using this update, so I think we’re all good. If anyone does notice something that fails due to version change, please let me know.

As always I appreciate the positive reviews, comments, and links. Thanks!

The Wealth Algorithm

I took a brief detour from PHP tutorials to write a book for people under 30 years of age, who want to become wealthy. It’s book that shatters a lot of myths, includes useful information, and is very accessible to a younger audience. I wanted anyone from age 14 on up to be able to understand it.

I’ve always hated wealth creation books because they seem so fake, and I almost didn’t write it for that reason.
What I always noticed about these kind of books is that they were always so vague. You never seem to get something concrete from them, other than the statement of “avoid debt,” as if it took a clever person to figure that one out.

But then I thought about how I could do it better. Now everyone’s path to wealth is unique because no two lives are exactly the same, so I can’t avoid generalities in my book either. But on the other hand, I’ve come up with some very unique techniques for how to achieve personal wealth.

I felt like the main wealth algorithm, which is something I’ve loosely defined throughout my book, 99¢ Wealth, is something worth sharing and could have a big impact on people’s lives.

This was all made possible by the first application I ever wrote in PHP called Timekop. I wrote it a few years ago, but never released it. The programming was pretty hacked up and useless, but the idea was really cool.

The application measured wasted time on a daily basis and scaled it over a lifetime, so I could see the effect of wasted time over the course of my life. The results were a real eye-opener. And ever since then, I have applied scale and engineering principles to more than just PHP.

My personal wealth has grown dramatically since discovering all this. These techniques work and are worth learning.

In the book, I use various calculators to sketch out a roadmap towards wealth. The examples I use are typically American because I am an American, but I think anyone from anywhere in the world can benefit from my work.

Obviously, if you are from another country, you can change some of the assumptions to fit your local environment. But the overriding principles are universal. And anyone can follow them.

Those of you who know me as a diligent writer of PHP tutorials and my book Yii 2 For Beginners know how much care and effort I put into my writing. I did my best to deliver something valuable to all my readers. It’s off to a great start with reviews, I hope more will follow.

My 99¢ Wealth book is not written for programmers specifically, but would still be a benefit to anyone who thinks like an engineer. In my opinion, engineers and programmers are some of the brightest people on the planet, so most will breeze right through the material. It’s an easy read for bright people.

I also decided to stick with Leanpub.com for the publication of this book. There are a couple of reasons for this. One, I’m not a fan of Amazon. Two, I’d rather support the smaller enterprise. Things worked out well with my Yii 2 book and the leanpub staff is very responsive whenever I have a question. I like their platform.

It’s true I could probably benefit from more book discovery on Amazon, but since my blogs get a steady flow of traffic, I figure I will be driving most of the traffic to my books anyway.

Throughout all of my work, I’ve endeavored to help younger programmers learn skills that will help them be successful in life. This book on wealth is an accessory to that.

I’ve priced the minimum cost of the book at $.99. At that price, I get $.39 royalty per book sold. So obviously I’m not doing this for the money. At 99¢, the book is accessible to just about anyone. With Leanpub’s variable pricing, you can pay more if you feel you want to support my work that way. I do appreciate every sale of every book very much.

Also, the comments, likes, and especially positive reviews, are all greatly appreciated and drive me to keep working. The best feeling I can get from something I’ve written is that it’s useful. So that’s my mission, to write the most useful books I can. I hope they continue to serve you well.

Yii 2.0.5 Security Patch Released

Yii2 released a quick patch for the ViewAction class. You can read the release here.

I had problems when I tried to run composer update and apparently they are aware of an issue on the composer side. So if you are following along with the book and already have installed the framework, I don’t recommend upgrading until the problem is solved.

If you are doing a fresh install, then you should be fine with Yii 2.0.5. I will follow up when the problem is solved.

I will also try to carve out time to build my app from scratch with Yii 2.0.5, so that I can have a current build handy for any issues that might arise. I anticipate this will take a couple of weeks as I’m in the process of completing another book, which I will be talking about on this blog.

Also, thanks so much for the great reviews I’ve received on GoodReads.com. Right now we are 4.68 out of 5 stars average with 25 ratings and 7 reviews. I really appreciate all the support I got with this book, so thanks again.

MVP Minimum Viable Product

According to wikipedia, the term minimum viable product, MVP, is a term coined by Frank Robinson, and popularized by Steve Blank, and Eric Ries. I find this to be a very powerful idea, and one that works hand in hand with using a PHP framework, such as Laravel 5.1 and Yii 2.

So what is MVP? It’s easy to mischaracterize MVP as a product with limited functions and features because while it typically does have less features than the typical enterprise application, the goal is not minimalism.

The idea with MVP is that you stand up the minimum number of features you need in order to collect data back from the users, so you can validate your business model as you develop it. You build just enough to allow yourself to follow the breadcrumbs of data, then follow that data like a compass to determine your sense of direction.

The speed at which you prototype and process this early feedback is important. The idea is to incorporate the customer feedback into the build itself, and you can only do that if you are testing and validating often enough.

One thing that’s great about this process is that it eliminates the old arguments between creative people about what will work. Instead, we simply let the customers decide.

The good news for those of us who use PHP frameworks is that they can really facilitate the MVP process, and that’s how we should think about it, as a process.

It’s a process that maps to the processes being adopted by entrepreneurs and lean startups.

Eric Ries defined 5 principles that drive the Lean Startup process:

  1. ENTREPRENEURS ARE EVERYWHERE
  2. ENTREPRENEURSHIP IS MANAGEMENT
  3. VALIDATED LEARNING
  4. INNOVATION ACCOUNTING
  5. BUILD-MEASURE-LEARN

The last one, build-measure-learn really encapsulates MVP. You might be tempted to quantify your job as programmer to simply program what the entrepreneurs ask you to do, and shuffle off the build-measure-learn concept as their problem, but doing so makes you less valuable to them.

On the other hand, if you take the time to plug yourself into their process, you’ll find yourself becoming invaluable to the enterprise. You’ll be part of the team that provides insight and clarity to the objectives, based on the intersection of design patterns and application usage patterns, the latter being provided by the customer feedback. The concepts developed in the code and the concepts of the enterprise fuse into a single entity and you will find yourself being a facilitator of this.

Leveraging the strength of a php framework can be an integral part of this process. For example, you might work for a company that doesn’t know the difference between building user RBAC from scratch and using or extending the options that are readily available to them from Laravel, Yii, and other frameworks. You can help guide them through these strategies and implementations. And if you can do it quickly, you will be their hero.

That takes us back to our php frameworks. When you study these frameworks, you can’t help but fall in love with them. There’s almost always core functionality or a plug-in to cover your requirements, so you can prototype very quickly.

The main thing to understand in a MVP approach is that it’s development on the fly, objectives change with the inflow of data, and decisions and implementations must be made rapidly. In the midst of this kind of environment, there is no difference between your love for PHP frameworks and the other tools that are available to you, such as Bootstrap, jQuery, and love of the enterprise itself. Your passion for development will help drive the enterprise.

I’m going to leave it at that. This article is meant to be a brief introduction to MVP. I recommend reading the wikipedia article and perhaps The Lean Startup by Eric Ries. I need to get a copy myself. Although I practice many of the principles, I have never actually read the book. Isn’t that so typical?

I can however vouch for build-validate-learn, though I would modify it to build-validate-succeed. Learning is not enough. Sometimes you only learn that you didn’t succeed. Those lessons are always valuable, but the real objective is success. Keep testing/validating until you succeed or pivot into something else.

Anyway, I hope you enjoyed this post. Please comment, share, and like if you can, thanks!

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.

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.