Computer Science E-75
Building Dynamic Websites
Lecture 11: Frameworks
Dan Armendariz

CakePHP

====================

To give this code a shot, you must first get a few things ready:

- First, go to cakephp.org and download Cake 1.1.19.6305. You may find this link more convenient:

http://cakeforge.org/frs/?group_id=23&release_id=371

- Upload the downloaded CakePHP folder to your public_html on cs75.net. You will probably need to correct the permissions of all the files: 701 for folders, 600 for PHP files, 644 for everything else.

- Create a new database from DirectAdmin:
http://cs75.net/panel
If you don't have an existing one to work with.

- Log in to your database from phpMyAdmin:
http://cs75.net/phpmyadmin

- Use this SQL code to create the appropriate "addresses" table:

CREATE TABLE `addresses` (
  `id` int(36) NOT NULL auto_increment,
  `first_name` varchar(10) NOT NULL,
  `last_name` varchar(15) NOT NULL,
  `email` varchar(30) NOT NULL,
  `phone` varchar(10) NOT NULL,
  `comments` text NOT NULL,
  `created` datetime NOT NULL,
  `modified` datetime NOT NULL,
  PRIMARY KEY  (`id`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=10 ;

- Finally, rename:
app/config/database.php.default
to:
app/config/database.php

And modify the $default array to the appropriate login, password, and database. As an example, your $default variable might look like this:

var $default = array('driver' => 'mysql',
		     'connect' => 'mysql_connect',
		     'host' => 'localhost',
		     'login' => 'danallan_lecture',
		     'password' => 'mypassword',
		     'database' => 'danallan_lecture',
		     'prefix' => '');

- Ok! You should be set to go. Verify it's all set by opening your browser and visiting your new cake install. If you have trouble, take a look at CakePHP's manual:

http://manual.cakephp.org/view/32/installation
and
http://manual.cakephp.org/view/39/configuration

Even though this is the manual for CakePHP1.2, the basic install steps are the same for 1.1.

In this directory, there are several versions:

app3 - Initial scaffold
app4 - Taking down scaffolding to build our own structure 
app5 - "Add record" capability
app6 - "Edit record" capability
app7 - "Delete record" capability
app8 - Adding data validation

Each of these directories are called sequentially numbered versions of "app" because their contents belong in the "app" directory of your CakePHP install.

As an example: let's say you want to take a look at the code from "app4". Open up the directory and place the contents of "controllers", "models", and "views" into "app/controllers", "app/models", and "app/views", respectively, in your own CakePHP install.
