This tutorial will eventually serve as a good step-by-step example of the uses of Cake in a real production environment. I intend to begin with a simple example, and then build upon that with more advanced features. The example I’m using is an image gallery, which will begin with a basic gallery, then add image uploading, and ultimately user comments. For the moment, please treat this as a work in-progress.

Image Gallery

In this step-by-step tutorial we’ll be showcasing some basic functions of Cake by building an image gallery. Hopefully you will walk away with the knowledge of how to install and use Cake to create web applications by beginning with a simple structure and later adding extra functionality until a final product is created.

Table of Contents

The Product

Our final image gallery will include the following functionality:

  • The ability to browse through various images, each with a description and a date of addition.
  • Image upload capabilities to ease the addition of more pages. This will also incorporate the use of an ACL to manage who has permission to upload images.
  • User-posted comments on each image.

Images Table

Once we’ve got our plan constructed, we’re ready to create our database structure. Installing MySQL and creating databases are beyond the basis of this tutorial, so we’re going to assume you know how to do both of these things.

For the first few steps, we’ll only be needing the image table. This table will contain a unique ID number, an image name, the filename for the image, a description, and the ID number of the user who owns the image. For now, we can ignore this last field, as it will eventually correspond to the ID number of a user in the users table.

CREATE TABLE `images` (
`id` INT NOT NULL AUTO_INCREMENT ,
`name` TEXT NOT NULL ,
`filename` TEXT NOT NULL ,
`description` LONGTEXT NOT NULL ,
`owner` INT NOT NULL ,
PRIMARY KEY ( `id` )
) TYPE = MYISAM COMMENT = 'This table will include references to all images within the gallery';

Installing CakePHP

More later....

 
tutorials/image_gallery.txt · Last modified: 2005/10/25 22:47 by rzebram