Meet Raymond Lane Haas

Please help me and Marci welcome Raymond Lane Haas into the world! Raymond was born at Beth Israel Hospital in New York City on October 18, 2012, at 12:24am, weighing 7 lbs. 12.3 oz.

 

Check out his ever-growing photo gallery here on Flickr!

Yii NYC

I just started Yii New York City, a meetup for NYC-area developers interested in the Yii Framework. I'm hoping we can get together monthly, or every other month, and talk about the cool stuff we're building in Yii. There will be introductions, roundtable discussions, demos, and most importantly, free food and beer! My company, Control Group, will be hosting the meetups, and you should come check us out even if just for the awesome views of lower Manhattan.

If you're in or around New York City, go sign up for the group now! Otherwise, get involved and organize a meetup of your own!

Category:
Tags: ,

Controller Access Control With the Yii Rights Module

It's easy enough to determine how the Yii Rights module works when used to perform inline access control checks in your code. You simply call ($user->checkAccess($operation) === true), and the internal details are easy enough to dig into. But how does it work with your controllers to allow or deny access to a page (or more specifically, an action in your controller)?

If you haven't yet read up on access control filters, you should check out the official Yii Controller Basics first and get familiar with filter chains. Then come back and read the rest of this post.

> Read More
Category:
Tags:

Displaying Yii's CLinkPager "First" and "Last" Buttons

Yii provides an excellent set of tools for displaying paged data, namely the CListView and
CGridView widgets. These widgets are easy to use, are highly customizable, and provide the kind of pager that is in use all over the web. Which makes it all the more strange that the pager doesn't work quite as expected.

The strange default behavior is that built-in css attributes hide the "First" and "Last" buttons. In fact, if you're like me, you didn't even know that the pager had a "First" and "Last" button until you started looking into putting ones in there. If you view the page source and scroll down to the pager, you'll see these elements, each of them contained within <li class="first"> and <li class="last"> tags, respectively. These tags are targeted by a display:none css attribute contained in the default pager stylesheet.

I have no idea why these are hidden by default, but it's not too much work to make them visible.

Read on to see how to change:

to:

> Read More
Category:
Tags:

A Short Trip to New Orleans

Marci and I traveled to New Orleans recently, possibly our last chance for travel for some time! Check out some photos....

> Read More
Tags: ,

Using Yii ActiveRecord to Assign from a List of Values

Often times you'll have a database table containing a list of values, and you want to assign one of those values to another entity. Imagine you're assigning an author to a book, or a currency type to a sale amount, or a country preference to a user. In all these cases you have one table/class representing a list of values, and one table/class that stores, among other things, a reference to a value/instance in the first table/class.

Luckily, Yii makes it easy for you do implement this.

For this example we're going to focus on books and authors, because everyone still reads books, right?

> Read More
Category:
Tags:

Updating to the Latest Yii Framework

The good folks at Yii dropped their latest framework release, 1.1.9, on January 1 of this year. Updating my applications use to this new framework was comically simple thanks to a small trick: using a symbolic link to reference the framework.

Whether you're downloading Yii for the first time, or upgrading to the latest Yii framework, you can create a symbolic link in your web root directory like this:

ln -s yii-1.1.9.r3527/ yii

Also update the following webapp files and replace each reference to the hard link with a reference to the symbolic link:

  • /webapp/index.php
  • /webapp/index-test.php
  • /webapp/protected/yiic.php
  • /webapp/protected/tests/bootstrap.php

Now here's where this comes in handy: when you're ready to upgrade to a new Yii framework, simply download it and unzip it in your web root, and update the symbolic to point to the new framework. Boom, thirty seconds, you've upgraded.

(Of course it's only this easy if you haven't hacked any core framwework files. You haven't hacked any core framework files, right?)

Category:
Tags:

Making Candied Citrus Peel

Disclaimer: I'm not really into the December holidays. We had quiet Hannukah celebrations growing up and I was always turned off by Christmas displays. Probably has something to do with being raised in a mostly Jewish suburb of Cleveland, Ohio. My wife, though, had a much different upbringing (ask me about it someday). She loves the holiday traditions and embraces the season, so I've become accustomed to having both menorahs and a Christmas tree in the apartment. Slowly and begrudgingly I've found peace with all these festivities. I still cringe when the George Michael, Annie Lennox, and Mariah Carey come on the stereo, but on the other hand I do love me some Yule Log dvd.

One tradition that I can definitely get behind, though, is the exchange of holiday kitchen creations. There's nothing like Susan & Diane's exquisitely packaged cookie box, or Amorette & Elizabeth's winter homebrew and homemade bitters. As much as I'd love to just sit back and let the treats roll in, I knew I had to up the ante and create something of my own. Since I don't have years of kitchen experience like a lot of my friends, I decided to start with something simple: candied citrus peel. You can get a pleasing variety of colors, you can pack 'em up into little gift bags, and unless you really botch a step they're really hard to fuck up.

> Read More
Category:

Installing Yii Users and Rights in 5 Steps

So you've got your clean Yii installation*...now what? Frequently the next step is adding support for users and some sort of permissioning schema. The official Yii guide to Authentication and Authorization is a very comprehensive and important piece of documentation — please do take the hour or so necessary to read it and try to understand it. You could skip it, of course, and just use the following steps to get your app working, but you'd really be missing out, especially if you're new to Yii, new to object-oriented PHP, or just new to authentication/authorization methodologies.

Anyone could roll his own user and permissioning framework, but luckily there are two well-supported Yii extensions for this: yii-user and rights. Both come with installation instructions, but I'm writing it all out in steps for easy reference.

By the way, I've created a github repository with a working version of my installation. You can grab it here, or just clone it:

git clone git@github.com:benjaminlhaas/Yii-with-Users-and-Rights.git

If you use this, you'll need to run the two migration scripts in the webapp/protected/migrations directory and probably change some directory permissions. Check out the README in the root.

If you still want to install yii-users and rights step-by-step, here are the instructions:

> Read More
Category:
Tags:

Installing Yii in 10 Easy Steps

I've been working with the Yii Framework for a few months now, and have been massively impressed so far. The amount of foresight that went into the design and architecture of this framework is mind boggling, and I keep getting reminded of this over and over again when I'm trying to get a very specific task done, and I learn that a well-documented, simple method or class already exists expressly for this purpose. I'm really surprised that Yii hasn't been getting a lot of chatter in the development community (at least from the people I've been listening to).

I've thrown together a few Yii applications so far, and I thought I would document a few installation/configuration processes for my benefit, and for anyone else who stumbles across this. All of this is available in disparate locations, including the official Yii reference, but I wanted to list things out as simply as possible, detailing how I got it to work for my setup.

> Read More
Category:
Tags:
Syndicate content