Archives For mvc

Nico, from Mémorandom, recently contacted me about translating my popular “Learning the Yii Framework” into French and publishing it on that site. I’m pleased to say that the first three parts of the series—Introduction to the Yii Framework, Getting Started with the Yii Framework, and Configuring Yii—have already been translated and are available online. This should hopefully help expand Yii’s international influence. My thanks to Nico for the nice words on my series and for the work in translating it!

Normally two Models in an MVC architecture are related to each other, such as Employees and Departments (to use the classic example), where each employee is in one department and each department has multiple employees. Although Yii does a great job of auto-generating most of the code you need, including the form used to create and update a Model, the Yii-generated form won’t properly represent the related Model. In this post I’ll walk you through what you need to do to make your forms work properly for related Models. Continue Reading…

On a recent Yii-based project, managing one of the Models required a whole slew of checkboxes to indicate that yes, the quality does apply, or no, it does not. In this case, the value being stored in the database for each attribute was a single letter: Y/N. However Yii, when showing the form to update an item, needs the checkbox value to be a Boolean, in order to properly pre-check the box. Changing the database wasn’t an option in this case, so I had to figure out a good conversion process. In this post, I’ll tell you exactly how I solved this issue. Continue Reading…

Some time back, I had written a couple of blog posts on authentication and authorization in Yii. As a comment to one of those posts, someone shared some code (also posted in the Yii forums) that requires a login to access any page. The interesting thing about this code is that it’s placed in the primary application configuration file, not within individual Controllers. The benefit to this approach is that a little bit of code can add authorization to your entire site, no matter how many Controllers you have. I’ll explain how to use this approach in this post, although keep in mind that it’s really best for situations where users must be logged in to access almost all of the site’s content. Continue Reading…

Some years ago, Rasmus Lerdorf, original creator of PHP, posted on his personal Web site a discussion of what he would look for in a framework for the MVC architecture. It’s an interesting read, from the master’s voice. He specifically talks about how to properly use MVC, how to guarantee performance and security, and how to design with scalability and flexibility in mind. Although the post is a few years old, most of it is still valid, although there are little changes such as the fact that the PECL/Filter extension is now part of PHP proper.

Lerdorf also posted his own thoughts on Facebook’s use of HipHop PHP for faster PHP execution, if you’re looking for something to read.