Wednesday, November 11, 2009

CakePHP - Adding Records to a Database Table

We have started creating our first CakePHP based application here.
Now to add a record to database table 'posts', I'll define add() function in the class PostsController (in 'app/controllers/posts_controller.php file).
Steps needed:
1. Open posts_controller.php file
2. Add following line of codes below index() function.


function add() {
 if (!empty($this->data)) {
  if ($this->Post->save($this->data)) {
   $this->Session->setFlash('Your post has been saved.');
   $this->redirect(array('action' => 'index'));
   }
}


Note:
First of all, the function checks, if submitted data is empty or not ( if (!empty($this->data)). $this->data contains the form submitted data.
Next, if there is some form data, we are telling Cake (short-form of CakePHP) to save it. ( $this->Post->save($this->data)  ).  '$this->Post' refers to Post model and  'save' method has already been pre-defined in Cake. So, you do not have to write them again. Thus the statement $this->Post->save($this->data) accepts all form data and save it to Post table. Note further, we did not fire up any SQL INSERT Statement to save our records.

$this->Session->setFlash('Your post has been saved.') statement generates a message and displays that message on screen.

 $this->redirect(array('action' => 'index')); statement redirects the user to the index() action for the controller. As such, you can redirect them to any page you like.

So, this is what our Controller does.

Now the view part. We need to create a form to add records.
To do so,
1. Create a new blank file (using any text editor).
2. Type the following code


<h1>Add Post</h1>
<?php
echo $form->create('Post');
echo $form->input('title');
echo $form->input('body', array('rows' => '3'));
echo $form->end('Save Post');
?>

3. Save the file as 'app/views/posts/add.ctp'
4. And you are done.

Note:
1. $form->create('Post'); tells Cake to create a new form and Cake creates following lines of code on the fly: <form id="PostAddForm" method="post" action="/posts/add">
2. $form->input('title');  tells Cake to create an input box for title field.
3. $form->input('body', array('rows' =&gt; '3')); tells Cake to create another input box (Textarea) with rows="3".
4. $form->end('Save Post'); tells Cake to create the submit button.
5. Here is the generated output with all default divs Cake has gladly added for you.

<form id="PostAddForm" method="post" action="/posts/add">
<fieldset style="display:none;">
<input type="hidden" name="_method" value="POST" />
</fieldset>
<div class="input text">
<label for="PostTitle">Title</label><input name="data[Post][title]" type="text" maxlength="50" value=" " id="PostTitle" /></div>
<div class="input textarea"><label for="PostBody">Body</label><textarea name="data[Post][body]" cols="30" rows="3" id="PostBody" ></textarea></div>
<div class="submit"><input type="submit" value="Save Post" /></div>
</form>


To access this page, type the following in your address bar:

http://caketest.local/posts/add

And here is a screenshot of my new Post Form
Now I can create a new blog post easily.
In my next step I will enforce some validation rules for this table (A.K.A. Model).


Thanks again.

CakePHP - Classes & File Name Convention with Example

In this topic I'll tell you the CONVENTIONs you MUST follow for Cake to work properly making your coding life SIMPLE.
You may already know (if you are following this tutorial...) that to create a database driven application you need to create following files.
1. One file to define data model (data model file)
2. One file to define how database queries should be processed (controller file).
3. One or more files to present the query results.
While creating these files you need to follow CakePHP naming CONVENTIONs. This is very important for the whole framework to work properly.

Database Table & Field Name Convention:
1. Create your database.
2. Table name convention - lowercase, plural, multi-word tables to be separated by underscore.
    Example table name:  posts
2. Each table must have one PRIMARY KEY to be named as 'id' (NOT NULL Auto Increment).
3. Field name convention - lowercase, multi-word field to be separated by underscore
    Example field name: id, title, body, created, modified
4. Foreign Key (related_table_name)_id

Model Name Convention
1. Model class names are CamelCased and Singular. (Like: Post, MyClass etc.). This should be the database table name.
2. Model filenames are lowercase, multi-word class is to be separated by underscore. (Ex: post.php, my_class.php)
3. Model files are saved under 'app/models' folder.

Controller Name Convention
1. Controller class names are CamelCased, Plural, and MUST contain the word 'Controller'. (Ex: PostsController, MyClassesController etc.)
2. Controller file names are lowercase, multi-word to be separated by underscore, and must contain the word '_controller'. (Ex: posts_controller.php, my_classes_controller.php)
3. Controller files are saved under 'app/controllers' folder.

Views Name Convention
1.View files are stored in /app/views inside a folder named after the controller class name they correspond to. i.e., for PostsController the corresponding view files are to be saved under '/app/views/posts' folder.
2. View filenames are function_name.ctp and saved under above path. (The function name is the name of the function you have used in corresponding Controller file.) This is really simple, if you go through the example below.    

Example Database & Table
1. In my case I created a database 'caketest_db'. You can create any database of your choice. You need to use this database name in your 'app/config/database.php' file.
2. Now create a table - posts.

SQL:

CREATE TABLE posts (
    id INT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
    title VARCHAR(50),
    body TEXT,
    created DATETIME DEFAULT NULL,
    modified DATETIME DEFAULT NULL
);


Add some data


INSERT INTO posts (title,body,created)
    VALUES ('The first CakePHP Blog Post Title', 'This is the first CakePHP blog post body.', NOW());
INSERT INTO posts (title,body,created)
    VALUES ('Second Blog Post Title', 'Second blog post body.', NOW());
INSERT INTO posts (title,body,created)
    VALUES ('Third Blog Post Title', 'Third blog post body', NOW());


Now create a post model
1. Create a new file.
2. Copy paste the following code

<?php    class Post extends AppModel 
         {      var $name = 'Post';  }    
?>
3. Save the file as '/app/models/post.php'. 
 And you are done creating your first post model.


Now create a post controller
1. Create a new file.
2. Copy paste the following code


<?php  
class PostsController extends AppController { 
   var $name = 'Posts';    
function index() { 
  $this->set('posts', $this->Post->find('all')); 
}  
}  
?>
3. Save the file as posts_controller.php inside the /app/controllers directory



In this file we have created a controller class for Post model. We have also defined a function index() ('Cake calls functions as 'action'). 
This is the default function to be executed by Cake. 
This function tells cake to find all rows from posts table and save it in a variable 'posts' (Note, $this->Post->find('all') - this is same as 'SELECT * FROM posts' ).

Now Create Views
1. Create a new folder 'posts' under '/app/views' folder.
2. Now create a new file
3. Copy paste the following code in that file

<h1>Blog posts</h1>
  <table>
  <tr>
  <th>Id</th>
  <th>Title</th>
  <th>Created</th>
  </tr>
 <!-- Here is where we loop through our $posts array, printing out post info -->
<?php foreach ($posts as $post): ?>
  <tr>
  <td><?php echo $post['Post']['id']; ?></td>
  <td>
  <?php echo $html->link($post['Post']['title'], 
  "/posts/view/".$post['Post']['id']); ?>
  </td>
  <td><?php echo $post['Post']['created']; ?></td>
  </tr>
  <?php endforeach; ?>
</table>
(You can get a copy of this code here! 
4. Save the file as index.ctp under '/app/views/posts' folder.

And you are done.
Now to see your result:

Point your browser to:
http://caketest.local/posts

You can see all records from the post controller.
Here is the screenshot:


Learn about Basic Principles of CakePHP - MVC Framework

Now that we have done some works with CakePHP this is right time to understand basic CakePHP principles. Let's take a look at the CakePHP folder structure.

These are the files and folders you should see soon after installation:
app (The folder where you will save your application files - like PHP files, CSS files Javascript files etc)
cake (The folder which contains core CakePHP files. You need to do nothing at this location)
vendors (The folder where you will install third party applications.)
.htaccess
index.php
README


Now take a close look at the folders under 'app' folder.

config : Holds the configuration files - like core.php, database.php, bootstrap.php, etc. 
You have already made changes in core.php and database.php files (if you are following my tutorial). So, you may have some idea about what they do.
models : Contains your application’s models, behaviors, and datasources.
As such CakePHP follows MVC (Model-View-Controller) framework. The Model represents the application data.  Simply, you will need to create a class for your database entities (tables). Using cake, you need not be a brain-scientist to define a class for your database table(s). As such there are different methods you can use to create a workable class on the fly. Believe me - it is amazingly easy. In the next step I'll try to create my own model class for a database table. The said class definition file will also contain field level validations and relationship between different database tables. You just need to follow Cake's convention to make things really easy for you.
controllers : Contains your application’s controllers and their components.
As per MVC framework, the Controller handles and routes requests made by the client. This is the place to save your application logics in the form of ControllerClasses. Like - you can set how to handle user login/logout requests, or, to add a new entry to your database tables. Once again, if you follow CakePHP convention - it is just a matter of few minutes to get these tasks done. 
locale : Stores string files for internationalization.
plugins : Contains plugin packages.
tmp : This is where CakePHP stores temporary data. It must be writable.
vendors : Any third-party classes or libraries should be placed here. 
views : Presentational files are placed here: like views, error pages, layouts etc.
As per MVC framework, the View renders a presentation of model data. Say, you have created a table for your blog post. To display your blog posts, you need to create a file under views. Once again, Cake has set its own conventions which you should follow to create view files. In my actual example - I'll show you how to do or what to do.


webroot : This is the folder to save your CSS stylesheets, images, and JavaScript files.
You may recall the file cake.generic.css resides inside this folder as 'webroot/css/cake.generic.css'. 

A quick summary
In a nut-shell, 
1. Create a database table.
2. Create a new file (model class file) for that table under models folder. (Cake now knows about your database table.)  
3. Create another file (controller class file) under 'controllers' folder to define how you want the various queries to be processed.
4. Create one or more files (views files) under 'views' folder to present the query results for different requests.


Once again, everything will work almost automatically if you follow Cake's Convention.   


Finally, if you follow convention - you can easily take full advantage of CakePHP MVC framework. As such, most coding will be done automatically for you!
So, in my next example - I'll try to present a real example while clearly spelling out basic CakePHP conventions.
(This may be criticized as an OVER simplified representation of CakePHP's basic principle. But I prefer to go with the minimum knowing well there are lot more stuff I preferred not to mention at this point... If you differ, you can always refer to any better authenticated source. Thanks.)

Follow my next post to go through a practical example.

Cheers!

Creating HTML Text Links with CakePHP

So, we have just created our about_us page. Now we need to create a link to this page. CakePHP has defined its own class for you to create links. The basic syntax is simple.

<?php echo $html->link('Link Text', 'Link URL'); ?>

For example: I wanted to create a link to http://book.cakephp.org

My Syntax:
<?php echo $html->link('CakePHP Book', 'http://book.cakephp.org'); ?>

And output:
 <a href="http://book.cakephp.org">CakePHP Book</a>

Note:
1. To create a link you need to echo the entire statement.
2. You can change link to point to any path - even relative paths.
3. You can use additional attributes to mention CSS class

Let us add a CSS class to that link.
<p><?php echo $html->link('CakePHP Book', 'http://book.cakephp.org', array('class'=>'ext')); ?></p>

Note the part I have marked with red ink. This link is now associated with class 'ext'. (Do not forget to define the 'ext' class in your css, in my case it is cake.generic.css file). And you are done.

To open this link in a new window:
<?php echo $html->link('CakePHP Book', 'http://book.cakephp.org', array('class'=>'ext', 'target'=>'_blank')); ?>
Note I have added 'target'=>'_blank' to that statement.

To add a javascript confirmation box to that link:
<?php echo $html->link('CakePHP Book', 'http://book.cakephp.org', array('class'=>'ext', 'target'=>'_blank'), "Do you really want to visit this website?"); ?>

Note I have added just the string to display and nothing more. Cake takes care of the rest of the stuff efficiently. And there's really much more to explore!

In my CakeTest Application now I'll display a link in the footer section to 'about_us' page.

I'll edit default.ctp (found under 'app/views/layouts' and add the following lines (mark with red color).


<div id="footer">
<?php

echo $html->link('About us','about_us',array('class'=>'footer-link'));

?>
</div>


Note:
I have not used the complete path to about us page, which is:
/pages/about_us
You need to specify just that 'about_us' part in place of the 'link url'. Cake does the rest successfully.

Further, I'll add a new style to cake.generic.css file (found under 'app/webroot/css')


a.footer-link:link,a.footer-link:visited, a.footer-link:active {
color:#C1C1C1;
font-size:10px;
background-color:#ffffff;
text-decoration:none;
}
a.footer-link:hover{
color:#C1C1C1;
font-size:10px;
background-color:#ffffff;
text-decoration:underline;
}


That's it.
Here is a preview:














That's it.

Cheers!

Tuesday, November 10, 2009

Create a Static Page, Set a Page Title Like About us Page using CakePHP

Let me try to create an 'About us' page with CakePHP. This is rather simple. This will explain how to create ANY static page with Cake (short form of CakePHP).
Also near the end, I'll tell about you about how to give your page a custom title using

$this->pageTitle = 'This is your page title'; 

To create About us page (Static Page Creation Example)
Just create a new file.
Write some text. You can use ANY HTML as well.
Save it as 'about_us.ctp' under 'app/views/pages' folder.
You are done.

You can access the page as:
http://caketest.local/pages/about_us

Important Note!
Note the word 'pages'. It is a CakePHP core controller. It displays any_name.ctp file saved  under 'app/views/pages' folder. I'll talk a lot about controller later. For the time being, it is just more than enough to know that you can create a new file, write some text, save it with a name under that path, and point your browser to:

http://caketest.local/pages/my_page_name

You should be able to view your new page.

Note again:
1. The pages MUST have a file extension of '.ctp'. (FILENAME should be underscored ('_'), like, my_file_name, to obey Cake convention.
2. Static pages MUST be saved under 'app/views/pages' folder.
3. To access the page you MUST use: http://caketest.local/pages/my_page_name

As such, you can change ANY or ALL of the above three settings in Cake. But it is better to accept default settings for most of the time - at least when we have just stepped into a new DOMAIN.


Page Title for your Static Page

Now to give this new page a custom page title copy-paste following code anywhere in 'about_us.ctp' file:

     <?php
     $this->pageTitle = 'Replace this with Your Own Title Here';
     ?>
I placed it at the top of my 'about_us.ctp' file for natural reason.

And here is my NEW Static About us page:

















You can create any static page like Privacy Policies Page, Terms of Service page etc. Just FOLLOW the conventions and Cake does the rest for you.

May I move on to explore some inner details of CakePHP, like creating LINKS etc.?

Cheers!

How to create a Custom CakePHP Template

So, I hope by far you have downloaded CakePHP (A.K.A. 'Cake'), installed it, changed security settings and connected to database.

You have seen the messages in the welcome screen has changed after each of your action.

Now you will note the following:
Editing this Page
1. To change the content of this page, create: APP/views/pages/home.ctp.
2. To change its layout, create: APP/views/layouts/default.ctp.
3. You can also add some CSS styles for your pages at: APP/webroot/css.
Create DEFAULT Home Page


So, I created a new folder called 'pages' under app/views/ . And then I created a new file (using any text editor) and saved that file as 'home.ctp' under 'app/views/pages/'.

Now point your browser to:
http://caketest.local/

You can see all the messages are gone!!! You can see this is a nearly empty page!


As the name says, 'home.ctp' is the default homepage for your website. You can write anything here (with HTML tags). Those will be displayed at your homepage.

Create Default LAYOUT

Now create another new file (using any text editor) and save it as 'default.ctp' under 'app/views/layouts/' folder.

'default.ctp' is the default layout to display your content. If it is empty, CakePHP will display nothing. This is exactly what you see after saving default.ctp - a completely blank page!!!

Do not worry!

Just copy and paste the following code in the newly created 'default.ctp' file.

--: BEGIN COPY :--



<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  <html xmlns="http://www.w3.org/1999/xhtml">
  <head>
  <?php echo $html->charset(); ?>
  <title>
  <?php __('My-CakePHP Tutorials'); ?>
  <?php echo $title_for_layout; ?>
  </title>
  <?php
  echo $html->meta('icon');


echo $html->css('cake.generic');


echo $scripts_for_layout;
  ?>
  </head>
  <body>
  <div id="container">
  <div id="header">
  Header Elements Will Go Here
  </div>
  <div id="content">


<?php $session->flash(); ?>


<?php echo $content_for_layout; ?>


</div>
  <div id="footer">
  Footer Text Goes Here!
  </div>
  </div>
  <?php echo $cakeDebug; ?>
  </body>
  </html>



----: END COPY :---


I have used red color to mark things you should note.
Change 'My-CakePHP Tutorials' to the title of your website. Like 'My Pet Dog Roombiq', or, anything you want.

NOTE:
There are FOUR IMPORTANT VARIABLES
$title_for_layout
$scripts_for_layout
$content_for_layout
$cakeDebug


The name suggests exactly what they do.
NOTE: 1
$title_for_layout MUST be included in between <title>  </title> tag.

<title>
  <?php echo $title_for_layout; ?>
</title>

As such, CakePHP gives a default title to every content page of your website following its own rules. But you can set a custom title as well. I'll show that in the next page.

NOTE: 2
$scripts_for_layout MUST be included before the closing </head> tag.


NOTE: 3
$content_for_layout MUST be included in between <body>
</body> tag.
<body>
<?php echo $content_for_layout; ?>
</body>

NOTE: 4
$cakeDebug SHOULD be placed before closing </body>

<?php echo $cakeDebug; ?>
</body>

AND you are done! You can add any CSS style/'div' layer to this page ('default.ctp') to give your website the layout/look you want.


For example, I tried a simple TWO Column Layout.

<div id="content">
  <div id="menu-box">
  menu items go here!
  </div>
  <div id="content-box">
<?php $session->flash(); ?>
<?php echo $content_for_layout; ?>
  </div>
</div>

I have added one div layer 'menu-box' and another one 'content-box' to display menu items and content items in two separate columns.
Now I need to add these CSS styles in a stylesheet file.

Modifying Stylesheet


As such Cake ('short-form of CakePHP) has already told us how to do that:
You can also add some CSS styles for your pages at: APP/webroot/css.
You can see the default CSS file under 'app/webroot/css' folder. The name of the file is 'cake.generic.css'. You can simply modify the content of this file (cake.generic.css).

I preferred to go to the bottom of that page and type the following lines


/* Custom CSS */

#menu-box{
width:250px;
float:left;
}
#content-box{
width:700px;
float:left;
}

It gives me a workable presentation for my custom template.

But I really need to make some more changes.

So, I just pressed (Ctrl+U) to view the source code, and I located the CSS division layers/ HTML tags being displayed in the source code, and modified them.

Here is the code: (Remember: I added the code at the bottom of cake.generic.css file.)


/* Custom CSS */

#menu-box{
width:250px;
float:left;
border-right:1px solid #CCCCCC;
}
#content-box{
margin-left:10px;
width:700px;
float:left;
border:1px solid #CCCCCC;
padding:10px;
background-color:#F3F3F3;
}
#header {
height:100px;
width:100%;
color:#000000;
background-color:#b5fad1;
font-size:2.0em;
border-bottom:1px solid #cccccc;
}
body
{
background-color:#FFFFFF;
color:#000000;
font-family:Verdana, Arial, Helvetica, sans-serif;
}

#footer
{
text-align:center;
}

..............................................................
And here is my custom template:














So, I have once again DONE that! If you are following me, you MUST have done so as well.

Congratulations!

Next, I'll try to create my 'About us' page using CakePHP. In general, I think this will give me some idea on how to create a static page with CakePHP.

Cheers!

CakePHP - Post Installation Work

So, you have installed CakePHP and you have seen the welcome screen.


Now point your browser to:
http://caketest.local/


Step: 1


The welcome screen says:
Please change the value of 'Security.salt' in app/config/core.php to a salt value specific to your application [CORE\cake\libs\debugger.php, line 557]




It is rather simple to get rid of this message.


Locate the file core.php under app/config folder.


Got it? Okay.


Change the default string of Security.salt value (something like 'EYhF23b0rvJFIxgx2GuvoUuBWwvniR2G0FgaC9mi') to whatever you want.  (I used 'EYhF23b0rvJFIxgx2' to replace the default string.)


And it was done. I could get rid of the first message. Hopefully, you have also got rid of that message.


Step: 2
The next message says:


Your tmp directory is writable.


In my case, I did not have any problem as my tmp directory was really writable. If you are trying it in a web server, you might have some problem.  And unfortunately if you have any problem, you can fix it by granting necessary permissions to your tmp directory.


Step: 3 
The next message says:
Your database configuration file is NOT present.
The message also says what should be done. 
Rename config/database.php.default to config/database.php


Okay. I did it. Simply follow that, i.e., rename the config/database.php.default to config/database.php.
Point your browser to:
http://caketest.local/
You can see that message has changed to give you a more friendly message:
Your database configuration file is present.
Let's move on to the next step.


Step: 4
The next message says:
Cake is NOT able to connect to the database.
For this you can't put blame on CakePHP. You need to configure your database configuration file. This is the same file we have just renamed - database.php. 


Look at that file closely. There is a class ('DATABASE_CONFIG') defined in it. Take a look inside the class. There is a member variable ($default) inside that class, which is an array itself! Do not be afraid. Simply go ahead reading.  I have marked the things you need to set with red color. Change the settings to match your database configuration. 


var $default = array(
'driver' => 'mysql',
'persistent' => false,

'host' => 'localhost',           /* I do not think you need to change it on most occasion. If it is anything   different other than 'localhost', then replace 'localhost' with the appropriate value, which you should know. */

'login' => 'admin', /* Replace 'admin' with your database username */

'password' => 'mypass', /* Replace 'mypass' with your database password */

'database' => 'caketest', /* Replace 'caketest' with your database name*/

'prefix' => '', /* This is to set table prefix. I'm not going to use any table prefic, so, it will be empty. */
);



Now point your browser to:
http://caketest.local


You can see a relieving message:
Cake is able to connect to the database.

So, I have done it!

I have downloaded, installed and run CakePHP. Further, I have made necessary changes to connect Cake (This is an abbreviation of CakePHP) to my mySQL database!

I hope you have come up to this point without much difficulty. In any case, if you have problem coming up to this point, just try everything from scratch. Install, change settings, follow step 1 - 4, and you should be able to have the same fun as I have right now.

Cheers! Let's be happy!

Not so much really. We need to make some more changes to make it look like my website. I'll do it in my next post.

Monday, November 9, 2009

Download & Install CakePHP

 To get started with CakePHP, you need to download the latest STABLE version. Visit CakePHP.org, hit the Download button, follow few step-by-step instructions to download your application.
Unzip the downloaded zip files.


Copy the downloaded files to your web server. 
My path is: C:\wamp\www\home\caketest (I copied everything under 'caketest' folder). 


Now point your browser to website url. In my case, it was:
http://caketest.local/ (I have a localhost configured. It should be something different in your case.)


I can SEE the welcome screen.


Yup! Cake is installed.


See the POST-INSTALL screenshot:


_ _ _ _ _ _ _ _ _ _ _ _ _ _
Previous Page ! Next Page

What is CakePHP?

CakePHP is a PHP Rapid Development Framework.

PHP Framework? What is it? Why should I rely on a Framework?

PHP developers are mostly self-trained (at least I am so) and being rather easy-to-develop, lots of developers jump-start developing applications without caring for code organisation/optimization and security. PHP applications developed by starters (I am a starter also and the same applies to me...) lack terrifically in proper organization. This makes maintenance/debugging of those applications a terrific task. Particularly, for large applications, it becomes a real challenge to DEBUG an unorganized code!

We badly need few norms (conventions) to follow so that each one can understand the logic of everyone else.

CakePHP does that. It sets few CONVENTIONs for following and also perform a lot of tasks automatically - like generating a web form from database tables (with ALL VALIDATION RULES), integrating AJAX (Yes! It does so! Even if you do not have much understanding of AJAX), creating sophisticated SQL queries (master-detail type even), and it does so in a better, sophisticated method without compromising with security or application performance.

That't it!!!

If you follow their conventions (I guess, a lot of people are already doing so...) , you can develop an workable application in a very short time.

BUT...

You need to know CakePHP CONVENTIONs and FOLLOW them brutally.

The book does talk really little about what you can do, or, can't (as such, you can do anything because core PHP will work like it has been doing even when you use Cake).

So, take the joy ride with me.

Cheers.

CakePHP Tutorial!!!

I was to develop a new application. PHP is my choice of scripting language. And database is MySQL. This time I tried to use a Framework. I scoured the Internet and found CakePHP (v. 1.2.5) is a Framework that can do all the magics. So I decided to go with it.

But to go ahead, you really need a good tutorial, which, I am afraid to say in this case is severely lacking.

There are some efforts to help readers in different forms, but I found a lot of helps rather confusing. Also there is a version problem. Most tutorials are old... and will not work with CakePHP 1.2.5.

Also, you need to undertake hours of searches to locate one or two simple cakephp specific functions! At times, this is very frustrating.

Oh! About the online book - http://book.cakephp.org is a good resource.
Do not forget to read it plus its comments. Though I have strong reservation in the way it has been organised, it would have been better.

My first impression was - (and is) - CakePHP is an excellent framework.

You can just do ANYTHING on the fly. But documentation is terrific!

So, while developing my application - I will share with you the way I am going.

This is not a tutorial...

I do not have the capacity or mastery to write a full CakePHP tutorial.

This will be just what I am doing & how! I will try to refer to different other related posts.

If it helps you, it would be my two cent.

My approach will be to organize pieces of pearls under own jewelery box! Here!

I'll try to index CakePHP vocabularies (core class libraries + function lists).

Once again, if it sounds useful, please visit me again and leave a comment.

Have a great day.