Recent Posts

February 2009

Beginning Cakephp – Errata : Pg 106

The findByYear() function is messed up in the book. Thought I would post the correction to remind myself.

Correct!

function findByYear($year=null) {      
	$date = $year.'-01-01 00:00:00';
	$end_date = $year.'-12-31 23:59:59';     
	return $this->find('all',        
		array(
			'conditions' => 
			array( 
				'DATE(Post.date) >' => $date,
				'DATE(Post.date) <' => $end_date          
			)       
		 )
	);   
}


Incorrect!

function findByYear($year=null) {
	$date = $year.'-01-01 00:00:00';
	$end_date = $year.'-12-31 23:59:59';
	return $this->find('all', 
		array(
			'conditions' => 
			array(
				'DATE(Post.date)' => '>'.$date,
				'DATE(Post.date)' => '<'.$end_date
			)
		)
	);
}

Ubuntu + VIM + CakePHP 1.2 + .ctp syntax highlighting

Found this blog post concerning setting up the Cakephp view extension (.ctp) to use the same highlighting as (.php).

blog

I didn’t find his solution that helpful, but one of the comments said to add this to my ‘.vimrc’ file in my home directory.


if has(”autocmd”)
autocmd BufEnter *.ctp set syn=php
endif

And since we are on the topic here is how my .vimrc is setup

set tabstop=2
set shiftwidth=2
set expandtab

if has("autocmd")
autocmd BufEnter *.ctp set syn=php
endif

syn on

-later

Cakephp + Ubuntu 8.04 + Apache2 Mod_rewrite

This tutorial assumes that you installed the basic LAMP stack that ubuntu comes with. It is also assumed that this is a development installation of CakePHP

1) Download CakePHP. My directory after I uncompress it is called ‘cake_1.2.1.8004′

*optional
2) Rename ‘cake_1.2.1.8004′ to ‘cake’

3) Move the ‘cake’ directory into ‘/var/www/’ so your full path becomes ‘/var/www/cake/’

4) Enable mod_rewrite

username@ubuntu:/$ sudo a2enmod rewrite
Enabling module rewrite.
Run '/etc/init.d/apache2 restart' to activate new configuration!

5) Enable appropriate rules in ‘/etc/apache2/sites-available/default’

username@ubuntu:/$ sudo vi /etc/apache2/sites-available/default

5a) Change the following

Directory /
Options FollowSymLinks
AllowOverride None
/Directory

To


Directory /
Options FollowSymLinks
AllowOverride All
Directory

5b) Change the following

Directory /var/www/
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
Directory

To


Directory /var/www/
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
/Directory

6) Restart apache2

username@ubuntu:/$ sudo /etc/init.d/apache2 restart

default screenshot

Cakephp

So, in my free time I am trying to write a web app for some folks at the District. I selected Cakephp as the framework for two reasons.

  1.  I know PHP
  2. It was suggested to me
  3. Ok, here is a third. It is freakin easy.

I needed something to develop in rapidly and am making progress with cake by leaps and bounds. The only thing that has really slowed me down is rolling my own RBAC. If there was a library to do this type of security, it would make life a lot easier.

The application itself is a Position Control System. With budget cuts at a state level, monitoring FTE with greater clarity and control is becoming very important. The complexities go beyond a normal system because of the way FTE can be transferred in a School District. I haven’t worked yet on how to calc these complexities, I only have identified them. But. I figure my solution will probably be interesting to some.

Once I have some code built, I will share.

-later