Monday, April 16, 2012

What's your preferred IDE?

Currently, still, it appears to be screen/byobu plus vim.

Probably I am missing all the niceties of something like netbeans, but here's how I set up a cakephp environment:

create a file that contains paths to sections...
---BEGIN FILE ---
cd /path/to/app/Controller
screen -t Controller
cd /path/to/app/Model
screen -t Model
cd /path/to/app/View
screen -t View
cd /path/to/app
screen -t app
cd /path/to/app/webroot/js
screen -t js
cd /path/to/app/webroot/css
screen -t css
cd /path/to/app/webroot/tmp/logs
screen -t logs
---END FILE ---

If you're using tmux instead of screen:
---BEGIN FILE---
cd /path/to/app/Controller
tmux new-window -n Controller
cd /path/to/app/Model
tmux new-window -n Model
cd /path/to/app/View
tmux new-window -n View
cd /path/to/app/
tmux new-window -n approot
cd /path/to/app/webroot/js
tmux new-window -n js
cd /path/to/app/webroot/css
tmux new-window -n css
cd /path/to/app/tmp/logs
tmux new-window -n log
---END FILE---


then simply source the file when you want create the screens for our application
To change between screens, the default mappings of ctrl-a, number will get you there.

I also use :split within vim to work on multiple documents within a given structure. I find this *generally* gives me a quick and easy way to handle the substructures I need and keeps me organized. The few other things most IDEs also have (like class trees and completion) I haven't yet had to use, but I figure I could also macro that as I need. On the logs screen, I can tail -f debug.log.

Tuesday, April 3, 2012

CakePHP helper to suggest input

What's it do?
makes it easier to make a gray suggest input box. Just use drop it as InputHelper.pm in View/Helper/ and call it where and how you need it. call it just like Form->input but add a sample text for the box.
$this->Input->input(fieldname, options array, 'sample text');

As an example, see what happens when you click in , click out, and change the content this box.




<?php App::uses('FormHelper', 'View/Helper');
/* helper to make default input help that disappears when clicked */
/* usage: $this--->Input-&gt;input */
class InputHelper extends FormHelper {
public function input($fieldname, $options=array(null), $fill) {
$options['class'] = ' dimmed';
$options['value'] = $fill;
$options['onClick'] = "if (this.value=='".$fill."') {this.value='';this.style.color='black'}";
$options['onBlur'] = "if (this.value=='') {this.value = '".$fill."'; this.style.color='gray'}";
$out = parent::input($fieldname, $options);
$out .= parent::hidden($fieldname . "_hidden", array('value' =&gt; $fill));
return $out;
}
}
?>

What's with the hidden? If you want to know what the original content was, you can test against this in your Controller to see if fieldname value is equal to fieldname_hidden value and don't store if it matches.

Blog Archive