A Year with Yii…
Well it hasn’t been a year, since I first was introduced to the framework “Yii”, but it seemed like a nice title. More like 8 months.
It appears that 8 months is the magical time when you get your first teeth. My daughter’s first tooth is making its debut this week. Which means not much sleep for dad. After a week of up all night, I find myself a little insomniac.
Now I sit awake, head spinning with programming thoughts. As I do most nights, I contemplate on what I am working on and brain storm new ideas as I go over it in my head (usually before falling asleep).
Why not blog? Maybe it will clear some of my thoughts.
It has dawned on me that I’m actually starting to feel comfortable with Yii. I’ve had some time to work with it now. Yii is a php framework for rapid web development. I first became acquainted with it in the fall of 2011 during my PHP Level 2 course at BCIT. We had to choose a framework to use in a project and present it to the class. It was a tough decision at the time, there are a lot of PHP frameworks and they are all so daunting. Unlike JavaScript where they pretty much pushed us in the direction of the framework, jQuery (no complaints here about that).
I’m glad I chose Yii, not only is it one of the newest, it has turned out to really grow on me and proven to be a powerful tool. I’ve had some time now, to pursue my interest in the Ruby programming language. And the Yii framework is similar in it’s approach to MVC as is Ruby’s rails framework. I was a little tempted to switch to Ruby for my projects, but because I’m not at the virtual private server level with any of my projects, it doesn’t seem worth it for shared hosting. But because Yii has it similarities to Rails I’ve settled with being a PHP guy.
I can see now Yii has made me a better programmer. I look at some of the PHP I’ve written before using a framework, and I can see all the short comings so clearly. A little SQL here, a whole lot of procedural programming there, and a dash of HTML because I was in a hurry. When I’m in a hurry with Yii, it is all already separated and structured for me before I start working.
Even in other languages, I find myself structuring my projects with a MVC look. I just finished an advanced java class at BCIT. One project was to build a database management application (ie phpmyadmin but desktop). My teacher gave me a good grade and told me “it was heavily over engineered”. I took it as criticism at first, until another classmate opened my eyes to the fact that it is better to be over engineered than under. And this played out to be oh so very true, because for the next assignment I needed to extend the first assignment’s functionality. With my project nicely laid out in an MVC way, the changes were minimal and the second assignment happened very quickly for me.
I started using Yii heavily in my personal website. This is where the learning and familiarity began. I created behind the scenes invoicing for customers, if need be. This required a few models, and opened my eyes to RBAC, role base access control. When I first used Yii for my PHP level 2 project we cut a lot of corners to get the project done. Doing a lot of things outside of Yii’s framework. Had I known that cutting corners only made it harder… But that is how it is when you start learning a framework. You don’t know how to do everything with it. Using it in my own site, I took the time to learn the right way. Which in the end was the wrong way I’m sure for some things being that it was my frist time, but that is how you learn.
I then turned to my company’s website, where I work during the day, and tore it down. I replaced it with a brand new Yii site, and included an extension for CMS. Learning more along the way.
Recently I took that company site and have started building a backend to replace some C#.net applicationa I’ve written for the company. Moving away from the .net desktop application was a personal choice. Hence becoming a mac user, I really didn’t like having to virtual box to code.
While I’ve been working on this project, it finally clicked, and I got it. Me and Yii gelled. Everything started making sense, and I stopped trying to fight the framework, but instead utilized it’s power. I was familiar with it and knew what to use.
And, it has made me learn even so much more about PHP! Just like when me and jQuery first had our “Ah ha!” moment, jQuery helped me learn more about JavaScript. I know people think frameworks hide the language and make newbies learn less about programming. But if you really get to know a framework, you start to get to know its inner programming. And if it is written well, you learn more about the language it is written in.
I think that it takes time for a framework to become useful to you. You will fight them at first. It will always feel longer when using a new framework. All the time you will waste reading online documentation just to figure out something so simple to do. Something you could so easily do with out the framework and just your programming language. But if you give a framework time, and learn it well, they will work magic for you and empower you. (don’t waste time writing a framework, it’s already been done for you)








