Welcome to Scribd. Sign in or start your free trial to enjoy unlimited e-books, audiobooks & documents.Find out more
Standard view
Full view
of .
Look up keyword
Like this
0 of .
Results for:
No results containing your search query
P. 1
Cakephp Example application

Cakephp Example application



|Views: 10,201|Likes:
Published by prak_sophy4252
In this section, you can walk through typical CakePHP applications to see how all of the pieces come together.
In this section, you can walk through typical CakePHP applications to see how all of the pieces come together.

More info:

Published by: prak_sophy4252 on Dec 18, 2008
Copyright:Attribution Non-commercial


Read on Scribd mobile: iPhone, iPad and Android.
download as PDF, TXT or read online from Scribd
See more
See less





1.2 Collection1.1 CollectionGeneral
Welcome to The Cookbook 
The Manual»Example Applications 
10 Example Applications
EditComments (2)History 
In this section, you can walk through typical CakePHP applications to see howall of the pieces come together.Alternatively, you canrefer toCakeForgeand the Bakeryfor existing applications and components.
See comments for this section 
EditView just this sectionComments (1)History 
Welcome to Cake! You're probably checking out this tutorial because you wantto learn more about how Cakeworks.It's our aim to increase productivity and make coding more enjoyable: we hope you'll see this as you dive intothe code.This tutorial will walk you through the creation of a simple blog application. We'll be getting and installing Cake, creating and configuring a database, andcreating enough application logic to list, add, edit, and delete blog posts.Here's what you'llneed:1.A running web server. We're going to assume you're using Apache,though the instructions for using other servers should be very similar.We might have to play a little with the server configuration, but mostfolks can get Cake up and running without any configuration atall.2.A database server. We're going to be using mySQL in this tutorial. You'llneed to know enough about SQL in order to create a database: Cakewill be taking the reins from there.3.Basic PHP knowledge. The more object
oriented programming you'vedone, the better: but fear not if you're a procedural fan.4.Finally, you'll need a basic knowledge of the MVC programming pattern.A quick overview can be found in Chapter "Beginning With CakePHP",Section :Understanding Model
Controller. Don't worry: its only ahalf a page or so.Let's get started!See comments for this section 
10.1.1Getting Cake
EditView just this sectionComments (2)History 
First, let's get a copy of fresh Cake code.To get a fresh download, visit the CakePHP project at Cakeforge:http://cakeforge.org/projects/cakephp/and download the stable release. Forthis tutorial you need 1.2.x.x
Table of Contents:The
1 Beginning With
 2 Basic Principles of 
 3 Developing with
 4 Common Tasks With
 5 Core Components 6 Core Behaviors 7 Core Helpers 8 Core Utility Libraries 9 Core ConsoleApplications 10 Example Applications10.1 Blog 10.2 Simple UserAuthentication 
10.3 Simple Acl
controlled Application 11 Appendices 
All in one page Suggest a new sectionhere 
Comments for ExampleApplications Change history forExample Applications 
LoginTop ContributorsTodoAbout CakePHPDonate
You can also checkout/export a fresh copy of our trunk code at:https://svn.cakephp.org/repo/trunk/cake/1.2.x.x/ Regardless of how you downloaded it, place the code inside of yourDocumentRoot. Once finished, your directory setup should look something likethe following:Now might be a good time to learn a bit about how Cake's directory structureworks: check out Chapter "Basic Principles of CakePHP", Section :CakePHP FileStructure
 boSee comments for this section 
10.1.2Creating the Blog Database
EditView just this sectionComments (4)History 
Next, lets set up the underlying database for our blog. Rightnow, we'll justcreatea single table to store our posts. We'll also throw in a few posts rightnow to use for testing purposes. Execute the following SQL statements intoyour database:The choices on table and column names are not arbitrary. If you follow Cake'sdatabase naming conventions, and Cake's class naming conventions (bothoutlined in"CakePHP Conventions"), you'll be able to take advantage of a lot of free functionality and avoid configuration. Cake is flexible enough toaccomodate even the worst legacy database schema, but adhering toconvention will save you time.Check out"CakePHP Conventions"for more information, but suffice it to saythat naming our table 'posts' automatically hooks it to our Post model, andhavingfields called 'modified' and 'created' will be automagically managed byCake.See comments for this section 
/* First, create our posts table: */
title VARCHAR(50),
body TEXT,
/* Then insert some posts for testing: */
INSERT INTO posts(title,body,created)
VALUES('The title','This is the post body.',NOW());
INSERT INTO posts(title,body,created)
VALUES('A title once again','And the post body follows  INSERT INTO posts(title,body,created)
10.1.3Cake Database Configuration
EditView just this sectionComments (2)History 
Onward and upward: let's tell Cake where our database is and how to connectto it. For many, this is the first and last time you configure anything.A copy of CakePHP's database configuration file is foundin
. Make a copy of this file in the samedirectory, but name it
The config file should be pretty straightforward: just replace the values in the
array with those that apply to your setup. A sample completedconfiguration array might look something like the following:Once you've saved your new
file, you should be able to open yourbrowser and see the Cake welcome page. It should also tell you that yourdatabase connection file was found, and that Cake can successfully connect tothe database.See comments for this section 
10.1.4Optional Configuration
EditView just this sectionComments (3)History 
There are two other items that can be configured. Most developers completethese laundry
list items, but they're not required for this tutorial. One is defininga custom string (or "salt") for use in security hashes. The second item isallowingCakePHP write access to its
folder.The security salt is used for generating hashes. Change the default salt valueby editing
line 153. It doesn't much matter what the newvalue is, as long as its not easily guessed.The final task is to make the
directory web
writable. The best way todo this is to find out what user your webserver runs as (
<?php echo`whoami`; ?>
) and change the ownership of the
directory to that user.The final command you run (in *nix) might look something like this.
var$default= array(
* A random string used in security hashing methods.
$chown-R www-data app/tmp

Activity (52)

You've already reviewed this. Edit your review.
1 hundred reads
1 thousand reads
Matt Janecek liked this
Ion Berges Gonzalez liked this
Kamil Kołcz liked this
Kamil Kołcz liked this
Vignesh Manicka Diwakar liked this
Saurabh Agrawal liked this
cakedoc liked this
trungdung1001 liked this

You're Reading a Free Preview

/*********** DO NOT ALTER ANYTHING BELOW THIS LINE ! ************/ var s_code=s.t();if(s_code)document.write(s_code)//-->