Interactive Plugin For CakePHP Console and DebugKit

I teased this on twitter last week, so here’s the official release. The interactive plugin is a super easy way to run code against your Cake app. You can use it either through a custom panel in the DebugKit or from the command line as a shell.
Download
Get it at GitHub

Instructions
I’ll skip the install instructions, since they’re included in the README. It’s pretty easy to install. If you’re using the latest stable release of the DebugKit you do need to apply a patch for better plugin handling. That fix is already in the trunk, so it’s not a dirty hack.
What It Can Do
Let’s get right to the good stuff.
Run Simple PHP
Pretty much any simple PHP commands will run:

10 % 4 //returns 2
is_array(49) //returns false

Run SQL

SELECT id FROM users WHERE email = '[email protected]' //returns the id of the user
UPDATE posts SET published = false; //returns "No results found.", but does the update.

Use Cake Functions

__('Test Message', true) //returns the translated text matching the msg id for your current language.
Configure::write('Config.language', 'es');
__('Test Message', true); //returns the translated text in Spanish.

Use Cake Libs

Security::hash('my_pAssw0rd', null, true) //returns the hashed password
Set::extract('/id', array(array('id' => 3), array('name' => 'test', 'id' => 4))) //array(3, 4)

Use Cake Helpers

$html->link('Posts', array('controller' => 'posts')) //the html code for the link and the link itself
$form->input('Post.title'); //the html code for the field and the field itself

Use Your App Code

Post::find('first') //The first record from your posts table
User::findById(3) //The user record for id 3

Debugging
If you have a command that isn’t returning the results you expect, you can turn on debug first:

Configure::write('debug', 2);
User::findByIdd(3) //will show error output

Notes
When using through the DebugKit you can stack commands, just separate them with a “;”. However you can’t define a variable in one command then use it in another. For example this doesn’t work:

$i = 10;
$i ++;
echo $i;

You’ll also notice I never explicitly declared any of the models I was using. The plugin does this automatically. You can write your model calls statically or just pretend you have an instance. These are all the same and will work:

Post::find('first');
$Post->find('first');
Post->find('first');
$this->Post->find('first');

The DebugKit = Awesomeness
Like most of you, I read this post from Mark Story on the new JavaScript for the DebugKit. Just reading that post, you don’t get a full appreciation for how much work he (and others) have put into it. The JavaScript lib is virtually it’s own mini-framework. Everything I needed to create this was already included – Ajax, Event handing, Elements…Really great stuff.
That’s About It
Let me know if you hit any commands you want to run that aren’t working. I tried to cover most of the basics.