Tag Archives: Yii 2

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.

Advertisements

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

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 For Beginners Update Image and File Management

I’m pleased to announce today the latest update of Yii 2 For Beginners with over 100 pages of new bonus material as of 3:00 pm pacific standard time on March 26, 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. Just login into your leanpub.com account and pull down the latest version. 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.

I worked really hard to get this bonus material out to you, it covers a lot of new techniques, including use of Yii 2’s scenarios. The page count of the book is now over 600 pages. For those unfamiliar with the book, we take you step by step through setup and installation and then onto coding a reusable template.

The book features:

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

More will be coming…

In this bonus material from this release, we cover basic image management, which includes uploading, updating and deleting both images and thumbnails. We also build a dynamically-driven carousel widget that is controlled by our admin UI.

You can set things like font size of the caption, show captions or not, show controls or not, etc., all from the backend UI.

This means you can hand total control of a key marketing area on the template over to the client and they will love that. Marketing is very important to clients and site admins and they will appreciate this level of detail.

I also went back to chapter 14 and added in the formatProviderResponse method both Google and Linkedin, which I had previously omitted. I’ve also included step by step instructions for setting up Google and Linked Apps, including screenshots to help you along.

While I was busy writing this update, some of our readers left positive reviews and comments on GoodReads.com, this blog, and the feedback section of the book’s landing page on Leanpub.com. This really inspired me to go all the way with the data-driven carousel and see how cool we could make it. I hope you like the results. I also hope you will contribute some positive comments and reviews of your own.

A number of readers also wrote in with typo notices and I jump on those immediately, with the turnaround within a few hours to 1 day. Everyone appreciates the efforts of all involved, it makes for a better reading experience for everyone.

Working on the Yii 2 framework is an amazing journey and I really enjoy sharing it with you. Thanks again for supporting our efforts.

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.