Tag Archives: php

100 Patterns For Success

I found in my personal journey to learn programming that design patterns were hard to understand at the beginner level.  The reason for this is that until you have some experience with implementations, the patterns are not going to be as understandable and you won’t see the benefit to learning them.

Seeing the benefit to something is key to learning it because you become motivated by the benefit and that drives you to overcome the difficulty of learning.

Before I go on, there is a great introductory article to design patterns on tutsplus.com that will give you a nice overview on design patterns, and includes examples of the following:

  • Strategy Pattern
  • Adapter Pattern
  • Factory Pattern
  • Decorator Pattern
  • Singleton Pattern

I wasn’t a big believer of the usefulness of these patterns in PHP until I studied the Laravel framework, which uses them extensively.  Now I’m still not any kind of authority on these patterns in Laravel, so I’m not going to give examples.  I’ll leave it to you to explore them on your own.  That said, the article is a great starting point.

If you are unfamiliar with Laravel, I did write Laravel 5.4 For Beginners to get you started, which  earned numerous 5 star ratings on GoodReads.com.

Laravel is an amazing PHP framework, which manages to distill things down to an intuitive syntax that is easy to grasp.  Where design patterns can be incredibly abstract and formal, Laravel is intuitive and simple.  It’s worth mentioning though that it achieves simplicity without sacrificing design principles and that is one of the things that makes it so powerful.

Anyway, I’ve always been inspired by Laravel and it’s community, since I was introduced to it a few years ago.  More recently, I listened to one of their podcasts, and the subject turned to books on entrepreneurship, which is one of my favorite subjects, since I’m also an entrepreneur.

Anyway, Matt Stauffer, the host of the show, talked about being disappointed by the book, “Rich Dad, Poor Dad” by Robert Kiyosaki, how the book didn’t seem to offer anything concrete, other than some musings about the psychology of success.

Personally, I’ve read that book.  It’s not a bad book.  On the other hand, I could see why programmers might not relate to it.

First of all, Kiyosaki is from an older generation that wasn’t very technical and that creates a disconnect.  It’s great that people were able to build empires through sheer street smarts and willpower, but programmers tend to admire the tech that has been built more than the money that it generated.

So if you did a bunch of real estate deals, and made a ton of money, it’s great, but not exactly inspiring to programmers.

A lot of books on entrepreneurship focus on the biography of the entrepreneur, which, while interesting, is not all that useful.  Richard Branson, for example, was thrown into a river as a five-year-old child by his father, so that he could learn to swim, which made him tough.  It’s a great snippet, but how does that help anyone else?  Personally, I won’t be throwing any of my kids into the water…

So I though about how a programmer would approach the subject of success and I realized that we could relate to it in terms of patterns, which as programmers, we have a natural affinity to.

After mulling it around a bit, I decided to step up to the plate and wrote 100 Patterns For Success, which draws on the success of millionaires and billionaires in tech.  I use their quotes, case studies, and my own observations to break success in tech into discrete attributes and patterns that you can adopt.

Here’s a short list of some of the people quoted in the book:

  • Peter Thiel
  • Elon Musk
  • Bill Gates
  • Mark Zuckerberg
  • Steve Jobs
  • Jack Dorsey
  • Larry Page

And many, many more tech millionaires and billionaires.  The quotes from these people are not simple quips or throw away lines.  They are mantras and insights that successful people live by.

We also look a case studies of successful entrepreneurs and the companies they founded. We talk about why, for example, Youtube was able to sell to Google within 1 year of founding for $1.6 billion, without ever having made a nickel in revenue.

That was not an accident and the odds were stacked in their favor from the beginning. The book has many other stories like this and shows you what they have in common.

The patterns in the book are meant to be helpful to you whether you are an entrepreneur or not.  In fact, I don’t recommend entrepreneurship to people.  Becoming an entrepreneur is not a rational act, since the odds of success are always stacked against you.

Instead, entrepreneurship is more about self-expression than anything else.  Yes, there is a financial motive, but if that’s all there is, then that entrepreneur is doomed before they even start.

Ever since I struggled to learn programming, I dedicated a lot of time to helping educate programmers from all over the world, to help them get past the barriers that would otherwise stop them from achieving their goals.  I know firsthand how hard things can be, nothing ever came easy for me.

Anyway, I hope you enjoy this book.  I put hundreds of hours of research into it.  The book is 298 pages in length, but it’s a gentle 298 pages, with a lot of white space.  We’re gotten some early reviews that have come back at 5 stars on GoodReads.com.

I’m very much aware that educational dollars are precious.  I’ve priced the book low so that my international readers will have access to it.  I’ve done my best to make it a fundamental resource that is critical to your development, both as a programmer, and as someone who wants to get the maximum benefit from your work.  I’m right there with you, in terms of wanting to benefit from programming work.

Thanks again to everyone who has supported my work over the past 4 years, I really appreciate it.

 

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.

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.

Yii 2 For Beginners New Bonus Material Released Growl and Rating System

I’m happy to announce today the release of bonus chapter 17, the latest update of Yii 2 For Beginners, with 60 pages of new bonus material as of 7:00 pm pacific standard time on April 6, 2015. Anyone who has purchased on or before that date, and that includes today, can login to leanpub.com and pull down the latest version of the book.

As always, updates and bonus material for the book are free for the life of the book. I highly recommend that you update to the latest version to get the most out of your purchase and take advantages of the new features built into the template.

In this bonus chapter, we utilize Kartik’s Yii 2 widgets extension, which includes numerous widgets that we will use, in this chapter, and in future chapters. Specifically, in this chapter, we will be working with the StarRatings widget and the Growl widget.

We create a functioning rating system for our Faqs, so users can rate them. You can use this as a prototype for any model that you want to have ratings for, so this is very handy.

We also implement the Growl widget, which takes a plain flash message and animates it, so you can add some life to the frontend.

We also do one cleanup task, which is to add a checkbox to the signup page, so we can have users agree to the terms of service. It’s a little detail, but since almost every application will require it, we provide a working solution.

And finally in this chapter, we return to the data-driven carousel to make it more adaptable to mobile browsers. Now, when the browser is scaled down, the carousel will switch to a mobile image that is also 100% controlled by our backend admin UI.

I felt it was really important to get this detail right. And after seeing some great comments and reviews on my book, I decided we couldn’t settle for second best, so I made sure we got what we needed. I think you will love the results.

Everyone appreciates the efforts of those who wrote in with typo notices, it makes for a better reading experience for everyone, so thanks to everyone who contributes.

I will continue to do my best to develop the template and bring you more bonus material. Any efforts on your part to help spread the word on the book will be greatly appreciated. Thanks again for purchasing the book and for your support.

Yii 2.0.3 Released

Yii 2.0.3 was released today, and while that’s great news, it means I have to make sure everything in my book, Yii 2 For Beginners, is 100% working with the update.

So, today, I ran the composer update and everything went smoothly. In about 2 minutes, I was fully up-to-date and you have to love this framework for that.

Just for those who are unfamiliar with composer, the framework files live in a vendor folder, and when you run composer update, it reads your composer.json file and brings your vendor files up-to-date with the latest versions and dependencies.

So composer knew that once 2.0.3 was released, 2.0.2 was out of date, and it stripped everything out and replaced it with the newer version. What a fantastic way to maintain a framework.

The Yii 2 advanced template is somewhat of a unique case however, because the template code lives in the backend, common, and frontend folders, and that can change with a version release. Yikes!

This means I have to check every aspect of the advanced template to see if there are any changes that impact the re-usable template we build in the book as well as the out-of-the-box code, since I take us through the complete setup and explain things like the site controller and the related form models.

I have to review all that line by line. I’m happy to report only one minor change in the login method, which I quickly updated in the book, so as of now, we are 100% code working and 100% compatible with Yii 2.0.3.

For those following along in the book, no change is necessary due to today’s version release. I do recommend that you stay current on the latest release and do a composer update.

I’m happy to say that I got the full review of the release and the update of the book done on the day of the 2.0.3 release. I know from your comments, emails and reviews that this hard work is helpful to a lot of people.

The readers of the book have been helpful too, letting me know about grammatical errors and other typos. I typically respond within 24 hours to email requests. There hasn’t been any code breaking in quite a while and we’re closing in on 100% of the grammatical errors. I really appreciate the help and it makes a better reading experience for everyone else and this is helping drive the positive reviews.

Since no other action was required on my part due to today’s release, this gave me a chance to tighten anything up that was previously less clear and to cover anything unusual.

For example, a reader wrote in to tell me that he couldn’t get the date to work on the profile model unless he added the php prefix in the validation rule:

[['birthdate'], 'date', 'format'=>'php:Y-m-d'],

I couldn’t reproduce his issue, but I thought I would mention this in case you run into a similar problem and I updated the book to reflect that.

Anyone who purchases the book gets free updates for the life of the book, all you have to do is login to your leanpub.com account and download the latest copy.

For minor issues, like the above, I generally don’t make email announcements. However, I’m also working on bonus material that I’m adding on a quarterly basis (approximately) and I have more new material coming soon, so there will definitely be an announcement with that release.

The core material in the book is 100% complete, and you can get up and running quickly with it. But the template we build in the book is also one I use personally, so I’m always working on it, and it only makes sense to share it with you. Those updates are free for the life of the book.

The other thing notable to me about today’s Yii 2.0.3 release is that this is the third minor release since the 2.0 release 4 months ago. This means you can have confidence that the Yii 2 framework is being very actively developed.

In their own words, Version 2.0.3 is a patch release of Yii 2.0 which contains about 50 minor new features and bug fixes. These include some performance optimizations for RBAC, Page caching for RESTful repsonses, and more. You can read about it here.

Even though a version release for Yii 2 is a hectic time for me, I really do enjoy it. I love the architecture of the framework, and reviewing it for a version release reminds me how easy it really is to use and how it just keeps getting better.

Let me end with a special thanks to all the programmers from around the world who participate in the this blog by reading the aricles, taking the polls, leaving comments and writing reviews. It is very much appreciated and keeps me working hard to continuously improve. Thanks again.

Yii 2 Custom Widgets

I hope everyone’s new year is off to a great start. Special thanks to everyone from around the world who has purchased Yii 2 For Beginners, I really appreciate your support. I also appreciate the positive ratings and reviews I’ve been getting, for example the two I got recently on GoodReads.com.

Your positive feedback keeps me motivated and recently I added over 100 pages of new material to the book. Anyone who purchases the book gets free updates for the life of the book, just log into your leanpub.com account to get the latest.

One of the recent additions to the book had to do with creating your own widgets. For those who are unfamiliar with Yii 2’s widgets, they are very handy for presenting data in the view. Yii 2 ships with a number of time-saving widgets that cover everything from navigation, grid results, pagination etc.

An implementation of a widget could start with a single line of code in the view:

echo GridView::widget(['dataProvider' => $dataProvider,]);

But typically with GridView, you will have a lot of customization of the columns and data-display formats, so the array inside the method signature can grow quite a bit.

Here’s what you might see from a basic user model in a backend admin view:

echo GridViewWidget::widget([
'dataProvider' => $dataProvider,
'filterModel' => $searchModel,
'columns' => [
['class' => 'yii\grid\SerialColumn'],

'id',
'username',
'email:email',
'status',
'created_at',

['class' => 'yii\grid\ActionColumn'],

],
]);

I’m not going to go into too much detail here, but you can see that the data is provided by the $dataProvider, and I don’t know how it can possibly be more intuitively named, so you have to love that.

The $dataProvider instance is being handed in from the controller, so you don’t have to supply any additional logic in the view. Next you supply it with a filter model, which is again handed in from the controller. Then you simply list the attributes you want to appear in the view.

The format of the email attribute creates a mailto link, and there are many ways to manipulate the appearance of the data.

We are also supplying classes for the look of the columns and a separate class for the ActionColumn, which contains icons and links to view, update, and delete individual records. This is just incredibly powerful out-of-the-box, especially if you are doing rapid prototyping of an admin area. We setup a much more complex version of this in the book, but you get the basic idea here.

One of the big points here is that you don’t need to put a foreach loop in the view, the widget takes care of it for you. So the widget is more of a configuration tool, not really doing much logic, and this helps to make your views incredibly clean. WordPress is chomping the code, so I can’t show you the shortcut echo tags, but you can use the shortcut because this is all really just one line, a bunch of settings handed into the array that sits in the method signature.

You will see very quickly how easy a widget is to place inside of a view, so much so that it spoils you a little. You're going to want a widget for everything.

While that’s not really practical, the good news is that you can easily create your own custom widgets. This article is more of an overview than a tutorial, so I’m not going to cover the complete setup, but I will give you an idea how it works.

Your widgets will extend Widget, with Yii 2 providing the perfect class structure for you to create these wonderful helpers. You start by overwriting your widget's two main methods, init and run.

Init just does the logic you want to perform, the result of which will be stored in the properties that you have named in the class. Then to pass the property values to the widget view, you use the run method, which renders the view with the values you have calculated in the init. The widget view is typically only a partial, which is going to sit inside of another view, making it portable and reusable.

So if you want to create a widget holding a top ten list from your content, and then use it multiple times on your site with just a single line call inside your view, you can do it. This is powerful stuff.

The cool part is how you hand in configuration from your widget call to the widget class itself. The Widget class is already structured to be able to receive an array. So you just set the array as a class property, and when the widget is called, the values of the array get handed in. Then you can use these values in the init to perform the logic you need for formatting the data.

Example:

echo MyWidget::widget(['settings' => ['pageSize' => 3]])

So imagine you wanted to build a widget where you had some results and you wanted to control the page size for pagination. In your MyWidget class, you would have a property declared as $settings = [];

In the code example above, you can see that we created the key/value pair that goes in this array, so this is assigned to the class property when the widget is called. So in your init method, you could perform logic using $this->settings[‘pageSize’] however you want. It’s that simple to move the data in. If this isn’t clear from my description, don’t worry, when you try it for yourself, you will see how it all fits together.

Although your run method need not include a view, it’s better to do it that way if you are creating output that involves html or css, which will most likely be the case. Then you just need to remember that when using the render method from within run, you need to access the properties via keyword $this, because unlike a controller, they will not be available to you otherwise.

The only other slightly tricky part to all this is setting up the application to have visibility on your custom components, which will be in its own components folder, and have its own namespace. I provide a full working example in the book, but that’s too much for here, so consult the Guide for instructions on that. Their widget section is fairly easy to follow.

Once you’ve had a chance to work with Yii 2’s widget architecture, it’s difficult to imagine coding life without it. I see it as yet another huge advantage of selecting Yii 2 as your choice for framework.

Yii 2 for Beginners Bonus Material Released

I’m happy to announce that the first chapter of bonus material for Yii 2 For Beginners has been released. The book has gone from a previous page count of 290 pages to 412 pages, so this is a very substantial addition.

Everyone who purchases Yii 2 For Beginners gets FREE updates for the life of the book. Just log into your leanpub account and download the latest version. I’m planning to continue to do updates and write bonus material for the foreseeable future. There are a number of reasons for this.

1. Striving For Excellence. I want to build a reputation for excellence and quality as a technical writer and I’m deeply committed to this project.

2. Framework Updates. I want to stay on top of Framework updates. The latest version of Yii 2 is 2.0.2, released two days before I released my bonus material. This meant I had to frantically rebuild the entire application from scratch, following the directions in the book, just to make sure everything is working. There were a few minor changes and I caught them all.

3. Maintaining the Template. The template we build in the book is a useful template for creating sites, including my own. I need to stay on top of version changes as much as anyone else, and as I’m doing that, it only makes sense to share the version improvements with my readers.

4. Sharing the Journey. Working with Yii 2 is an amazing experience that I would like to share with my fellow programmers and engineers. Working on this book is a way to express my passion for Yii 2 and grow at the same time.

I’d like to thank everyone who emailed or commented for the wonderful feedback, especially the positive reviews on GoodReads.

I really appreciated the notices on the typos as well. Most of the typos are trivial, but I still want to correct them. I won’t be satisfied until the book is 100% free of typos and I think we are probably close to that now.

I know for a fact the code is 100% working. The build I did over the past few days was from code taken directly from the book, via the gists, and it works perfectly. For anyone who doesn’t know, a gist is a code snippet hosted by Github.

Copying code from a PDF can be a real pain and I had multiple requests from readers to post the code. So, in response, I have supplied a gist for any block of code that is over 3 lines. The gists are inline in context in the book, so you just click a link and you get the relevant code. This means you don’t have to bookmark or organize anything, it’s already done for you.

New in this Update

1. Yii 2 Version Update. I already mentioned that Yii 2.0.2 was released a couple of days before I finished and this was perfect timing for me. The three notable changes concerning the template were:

A. The advanced template doesn’t ship with a role column on the user table like it did before.

B. Forgot password methods changed.

C. The typo generated by Gii when creating a controller has been fixed.

So nothing here required any dramatic changes on my part, just some instructional text had to change. This worked out well. I should point out that I ran into an unknown problem when I tried to run composer update, composer just got hung up. Another user experienced an issue as well.  My work around was to build from scratch. I had to do this anyway because I had to test everything 100% on a new build. My code is 100% compatible with both Yii 2.0.1 and Yii 2.0.2. If you do a fresh build, everything will work perfectly.  So that’s the good news there.

2. Fine Tuning Core Book. Doing an update always gives me the chance to go back over the instructions in the book to fine tune them for maximum clarity. I also catch typos, and obviously any bugs in the code. I can’t claim a 100% on typos, but I know the code is 100% working because I use it myself, and like I said before, I just rebuilt the application from scratch using the code from the book. Nothing in the core book changed in terms of how we were doing things, so nothing of substance to report.

For those that don’t know, the core book takes you through setup and install of Yii 2, then onto building a reusable template that also includes:

  • A Working user model
  • User registration and login
  • User Profile
  • Forgot password recovery
  • Frontend and backend separation with Admin UI
  • Helper classes
  • Access control
  • Free/Paid content control
  • RBAC with backend UI
  • JUI DatePicker
  • Bootstrap Mobile Responsive CSS
  • Facebook Social Widgets
  • Font-Awesome Implementation

The bonus material extends the core template with useful features, at the same time, we continue learning more about the framework.

3. Autoresponder. In the bonus material, we build an auto-responder. This is similar to the one I talk about on the blog, only this is the full set of instructions, with tested code. So again you know it’s 100% working.

4. Dropdown Navigation. We implement dropdown navigation links from my own solution. It’s quick and easy and you will love it.

5. We build an FAQ model for the template. FAQs are common to most sites and this will come in handy. This implementation has a full frontend/backend UI with extensible data structure. It is very useful code.

6. Components. We build the component application structure and show you how to create a component in the Advanced Template, including all the config details.

7. Custom Widget. Creating widgets are easy once you know how. This is a very powerful piece of the Yii 2 architecture that you will fall in love with. I will be blogging more about this in the future, it’s just amazing.

8. Closing A Potential Hole. There is no hole in the code if everything is coded correctly, but what happens when someone makes a typo? This section makes a nice adjustment to the ValueHelpers class that helps prevent accidental exposure.

9. CDN. We finish the first round of bonus material with a simple config implementation to use CDN for the core CSS and JS assets. This can dramatically increase the speed of the application.

All in all, it’s over 100 pages of new material. To reiterate, this is all 100% FREE to anyone who has previously purchased the book. Just log into your leanpub.com account to download the latest version.

I really had to work hard to get this to you in a timely manner. I put another book-writing project on hold, so I could make sure I live up to the commitments in supporting Yii 2 For Beginners. Now I need a few days off before I collapse from exhaustion.

Thanks again to all the readers from all over the world who were supportive with positive comments and are supporting my work. Your feedback motivates me to keep going. For example, on GoodReads, we are averaging 4 out 5 stars, with some nice comments even from the lower rating, which came before the additional 100+ pages of material was added to the book.

Please keep the comments, links, positive reviews, and word-of-mouth-referrals coming, they are greatly appreciated. See you soon.