AutoHotkey Guide for CakePHP
Tired of typing "class YourModelsController extends AppController..." over and over? If so this, is for you.
NOTE: This guide assumes you are using PHPeclipse as your IDE of choice. If you use another IDE or notepad you will have to adjust the AutoHotkey script accordingly.
Download code
Reload the script by right-clicking the taskbar icon and reload.
type ]cmod
It should prompt you for the model's name, so type your models name.
For controllers type ]ccon
Step 1
Download and Install AutoHotkey ( it's free ) - http://www.autohotkey.com/Step 2
Edit the default script to look like the following.Download code
;-----------------------------------------------------------------------------
; CakePHP
;-----------------------------------------------------------------------------
;model
:c*?:]cmod::
InputBox, MyModel, Model Name Prompt, Enter model name ( e.g. MyModel ),,250,125
if ErrorLevel=0
{
BlockInput On
Send, class %MyModel% extends AppModel{enter}{{}{enter}var $name = '%MyModel%';{tab}// required for php4 installs{enter}var $displayField = 'id';{enter}
BlockInput Off
}
return
;controller
:c*?:]ccon::
InputBox, MyModels, Models Controller Prompt, Enter controller name ( e.g. MyModels ),,250,125
if ErrorLevel=0
{
BlockInput On
Send, class %MyModels%Controller extends AppController{enter}{{}{enter}var $name = '%MyModels%';{tab}// required for php4 installs{enter}var $scaffold;{enter}
BlockInput Off
}
return
Step 3
Fire up PHPeclipse and create a model php file.Reload the script by right-clicking the taskbar icon and reload.
type ]cmod
It should prompt you for the model's name, so type your models name.
For controllers type ]ccon
Comments
Comment
1 textmate
there is one for cakephp to do things like this automatically.
Comment
2 SCiTE
It has the same snippets functionality as Textmate and they are user-definable with an easy-to-understand syntax. Just define a set of snippets you find valuable and it's just a keyword and ctrl-b away.
If anyone is interested, I can post my snippets file (known to SCiTE users as an abbreviations file).
Comment
3 Do It
:-)
Comment
4 Vim
http://www.vim.org/scripts/script.php?script_id=1318
Comment
5 PHPeclipse
/**
* @author ${user}
* @since ${date}
*/
class ${primary_type_name} extends AppModel {
var $$name = '${primary_type_name}';
var $$hasMany = array();
var $$belongsTo = array();
var $$hasAndBelongsToMany = array();
${cursor}
}
when you create a new model just type 'model' and press ctrl + space and eclipse inserts the model code. ${primary_type_name} inserts the filename without extension so there is almost nothing to do left :-).
Comment
6 GENNIT CakePHP Generator