CakePHP, Prototype & Json

Tháng Mười 7, 2008

In my recent blog, I’ve presented a development model, frameworks and tools for scalable, high performance systems as social networks. CakePhp, Prototype & Json are three tools that we must learn fisrt. In this blog, I would note some steps to use CakePHP, Prototype and Json together.

1. Download and install CakePHP 1.2x (I installed and run well in Slackware 12.0)

1.1 Download CakePHP 1.2x (Example: cake_1.2.0.7692-rc3.tar.gz

# wget http://cakeforge.org/frs/download.php/671/cake_1.2.0.7692-rc3.tar.gz

1.2 Extract and move to /www/ folder

# tar -zxf cake_1.2.0.7692-rc3.tar.gz

# mv cake_1.2.0.7692-rc3 /www/cake_1.2.0.7692-rc3

1.3 Modify /etc/httpd/httpd.conf

1.3.1. Enable mod_rewrite (just remove comment – uncomment)

LoadModule rewrite_module /lib/httpd/modules/mod_rewrite.so

1.3.2. Re-configure DirectoryRoot 

DocumentRoot “/www/cake_1.2.0.7692-rc3/”

1.3.3.  Add DirectoryIndex (index.php index.htm index.html) and modify AllowOverride ( All ) params to tag <Directoy> of “/www/cake_1.2.0.7692-rc3/”

<Directory “/www/cake_1.2.0.7692-rc3/”>

    DirectoryIndex index.php index.htm index.html

    Options Indexes FollowSymLinks

    AllowOverride All

    Order allow,deny

    Allow from all

</Directory>

1.3.4 Restart your apache

# cd /etc/rc.d/

# rc.httpd restart

1.4 Configure cakephp database, modify …/app/config/database.php

var $default = array(

‘driver’ => ‘mysql’,

‘persistent’ => false,

‘host’ => ‘yourservername_or_ip’,

‘login’ => ‘db_username’,

‘password’ => ‘db_password,

‘database’ => ‘db_name’,

‘prefix’ => ”);

You also can define more than one database, but you should define those with names are not ‘default’. 

1.5. chmod and chown cakephp ../app/tmp folder

chmod 775 -R /www/cake_1.2.0.7692-rc3/app/tmp

chown -R your_apache_account /www/cake_1.2.0.7692-rc3/app/tmp

Now, http://localhost/ is showing your cakePHP page (You should have break then go to the 2nd step)

2. Intergrate Json to CakePHP

3. Download Prototype and use with CakePHP

4. Sample

To be continous …