My First Simple CakePHP Webpage

June 14, 2007 at 6:09 am | Posted in tutorial | 10 Comments

1. Create a table.

– create using http:\\localhost\myphpadmin

– using SQL Codes

CREATE TABLE guestbooks (
firstname VARCHAR(50),
lastname VARCHAR(50),

address VARCHAR(50),
description TEXT,

Note: The name of the table is in plural form. (example: guestbooks)

2. Creating a .php file in app/models directory

filename is in singular form (example guestbook.php)

example code:

class Guestbook extends AppModel
var $name = 'Guestbook';

3. Creating a .php file in app/controllers

the file name must be filenameplural_controller.php (example: guestbooks_controller.php)

example code:

class GuestbooksController extends AppController
var $name = 'Guestbooks';
var $scaffold;

Note: the scaffold variable is use when there is no app/view .thtml file. If you paid attention to the previous example, you will notice that no view files were created. That’s because Cake uses predefined templates for scaffolding; in reality, you’ll need a view for almost every action listed in your controller.

The scaffold variable automatically create index.thtml, add.thtml, view.thtml and delete.thtml

That’s all you have your very first simple webpage using cakePHP!!!

Next time we will modify that page of by removing the scaffold variable…



RSS feed for comments on this post. TrackBack URI

  1. I just started CakePHP about a week ago. My jaw is still on the floor with all it can do.

    I’ve heard of Ruby On Rails but never looked into it because I wasn’t in the mood to learn a new language. CakePHP brings the Rails to PHP.

    Baz L
    Baz Web Development

  2. “That’s all you have your very first simple webpage using cakePHP!!!”

    It would be helpful to mention which file to run from browser, what folders to add to php.ini include, and other stuff like that since many new-to-cake people will be reading this.

  3. Hey Mariecon,

    I agree with Gavin, why not post a tutorial how you did it, not just using scaffolding though. I’ll help if you need one πŸ˜‰


  4. Hello rachel πŸ™‚

    Actually i have already make one hehehe…
    Take a look at this

    Thanks for dropping by…

  5. Thats great. I think I missed that when I was surfing your blog. Do you mind to document this for our google group? I think I invited you a few days ago.


  6. Hi rachel πŸ™‚

    Sure i’m glad to post there πŸ˜€

  7. Hi marie,

    I am a bit confused as the guestbook example is not working. i just did it was suggested but i am yet to meet with success.

    i have apache server. in httdocs i have placed the downloaded cakephp framework. And as suggested created the table,.php files in app\controllers adn app\models. and tried out using the link:


    But i am thrown the following error:

    “requested URL /cake/guestbooks/ was not found on this server”

    Can you please help me.


  8. Marie,

    One more thing.. is there any requirement to change paths in any of the files.


  9. very interesting, but I don’t agree with you

  10. I would like to see a continuation of the topic

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

Create a free website or blog at
Entries and comments feeds.

%d bloggers like this: