CakePHP 1.2 RC2 is available!
The cake team is working rather quickly. They have released Cake 1.2 release candidate 2 on June 27th. Time to upgrade once again! The goodness just keeps coming.
The cake team is working rather quickly. They have released Cake 1.2 release candidate 2 on June 27th. Time to upgrade once again! The goodness just keeps coming.
CakePHP RC1 was released on June 4th. At the moment I haven’t had much time to play with it as I wrap up a few projects using 1.2 beta. One thing I did notice was their inclusion of the Containable Behaviour. This is a powerful behaviour that helps in limiting the data you want to grab from your models. I’ve used both Mariano’s and Felix’s behaviours and I’m glad those forces were combined to produce this, and then some.
This weekend I’ll be upgrading my client sites to RC1 and hopefully all will go well. For information on what’s new in RC1, visit the bakery
I’ve posted this up at the bakery, but articles seem to take awhile to get published. It could also be that they’re working on a new ACL Behavior, one can hope. For the time being, I’ve fixed up the core behavior and added a few features as well. I’ll just replicate here what I wrote at the bakery.
This Acl behavior makes a number of improvements from the built-in one. It allows you to have a model act as both an “Aro” and “Aco”. It creates an alias in this format “Model.id”. If parent node is not provided, it’ll create one based on root object. For example, if you create Post.1 as an ACO and you set parentNode to null, it’ll set the parent_id to the root “Post” Aco if it exists. So your tree would look like the following:
Acos ---------- Post |-Post.1 |-Post.2 |-Post.3
Usage Instructions
Follow the following steps to use the Acl behavior.
Step 1
Copy the behavior class into a file named “acl.php” in your /app/models/behaviors folder.
Step 2
Load the behavior in the model you want to use it in.
Examples:
Ex 1: Act as Aco
var $actsAs = array('Acl' => array('Aco'));
Ex 2: Act as Aco
var $actsAs = array('Acl' => 'Aco');
Ex 3: Act as Aro
var $actsAs = array('Acl' => array('Aro'));
Ex 4: Act as Aro and Aco
var $actsAs = array('Acl' => array('Aro', 'Aco'));
Step 3
Create the method parentNode($type) in your model. This will return the parent_id to a method in the Acl behavior.
Here’s an example of a User model passing a group id as it’s parent id only for the ARO:
function parentNode($type) { if ($type == 'Aro') { if (!$this->id) { return null; } $data = $this->read(); if (!$data['User']['group_id']){ return null; } else { return array('model' => 'Group', 'foreign_key' => $data['User']['group_id']); } } else { return false; } }
That’s it!
Download the behavior class here
Sometimes it’s hard to remember certain things about technologies you use when developing a web application. I must admit that I frequent php.net occasionally to remind myself what parameters a function takes. With frameworks, extra php libraries, javascript libraries, and css it becomes increasingly more difficult to remember how to use all of these technologies. In comes the cheat sheet. Cheat sheets are great as a quick reference on how to use common features with a particular technology.
Here is a short list of useful cheat sheets:
Prototype 1.5 - by Jonathan Snook
Mootools r.83 - by Jonathan Snook
Scriptaculous - by Ryan Carter
CSS by Dave Child
You can find more of cheat sheets (PHP, mySQL, Javascript, etc) over at Dave Childs cheat sheet section
Jim Plush wrote an interesting article on what differentiates a PHP developer from a scripter in his opinion. He specifies in the intro that the criteria is for an ideal senior level developer. I agree with most of his criteria aside for the CSS requirement. I think it’s good for a developer to know CSS but if they are at the senior level then there’s a good chance they would never have to deal with the CSS in a project.
As for the other criteria he mentioned… I really need to touch up on unit testing :\
http://www.litfuel.net/plush/?postid=166