cakePHP – Registration Application

Agility – In Software Development, having this characteristic is one of the key to success these days. A lot of talented startups are using their flexible business models to quickly adapt to changes and widen their customer base. Developers are now adapting and embracing the “Jack of all trades” on a platform level as the demand for such is increasing day by day. Yet with all those agile web programming platforms, PHP stood out for me. Its simplicity and straight forward approach makes every developer feel the fulfilment of crafting an application. With the addition of several frameworks developed on top of it like cakePHP, yii, codeigniter etc, the capability of it just keeps getting better and better.

Moving on though, I’d like to show you how simple and agile a developer can be with one of the best Agile / Rapid Web Application Development Framework available: CakePHP

What are we going to do: Simple Registration process it has to have:

  1. Register a new person
  2. Edit an existing person
  3. Delete an existing person
  4. View all of the person
  5. User Interface for all

Its also note worthy that I will be doing all of these stuff as I write this down. I would say it may take you 15mins including the cakePHP initial code setup.


  1. I use MAC so this tutorial is solely for MAC users – although the only difference is the scripts and system path configuration which is the same as setting up environment variables in windows.
  2. I use MYSQL Database
  3. I use NetBeans PHP Plugin

Set it up: Download the cake and the bakery (its on 1 package only)

    • Download MAMP for your Web Server and MySQL Database
    • Install MAMP < Straight forward, execute the sh file and it will automatically generate the necessary folders
    • Locate htdocs inside MAMP < this is where you will locate your cakePHP and projects as this is the default directory recognised by your web server and php parser (you can actually change it to any custom directory you want, this can be done by changing the DocumentRoot of httpd.conf inside the apache folder).
    • Download the latest cake distro here:
    • Put it inside your htdocs folder (start your XAMPP to test).
    • if you see the screen below, then your on the right track!

  • Check the video for the .bash_profile: for the environment variables.
  • Export the following variables and values < This is to put the cake library in your classpath. This is important for you to easily access the commands for baking (code generation tool)
  • Test it!

Database Setup: Lets setup your database and table objects

  • Create a table named persons < This is cakePHP’s naming convention, tables are “recommended” to be plural as this will have multiple entries of a specific business data.
  • Create the columns: Id, first_name,last_name,birth_date,email_address. Again, convention wise, words are separated by _ and a sensible column name.
  • You are now ready to create your first cakePHP web application!

Cake Bake: Open terminal

  1. Type cake bake -app
  2. Type the location on where you want to put the app. In this case, put in htdocs folder.
  3. Skeleton folder is the default one so just press enter. Type in Y when ask if “Look okay?”.

Create a Database Connection called “default”.

  1. Database: Mysql
  2. Persistent Connection: For now, N
  3. Database Host:
  4. Port: 3306
  5. Username: <your db username>
  6. Password: <your db password>
  7. Database Name: registration_sample
  8. Press Enter all the way.

This will create a new “bakeable” project source code. Type in cake bake -app <location of the project source code>. This will run the cake bake command and will display a menu of code generators (screenshot below).

Generate Model Codes first: Press M

  1. Use the “default” datasource
  2. Choose 1. Persons
  3. Primary Key: 1. Id
  4. Display Field: first_name
  5. Validation Criteria for Fields: Y – this is where you define the validation. This will affect the validations on the user interface.
  6. Press Enter all the way

Generate Controller Codes: Press C

  1. Choose 1. People
  2. Press Enter up until the generation of basic class methods.
  3. Would you like to create some basic class methods index(), add(), view(), edit())? (y/n) = Y
  4. Would you like to create the basic class methods for admin routing? (y/n)  = N
  5. Would you like this controller to use other helpers besides HtmlHelper and FormHelper? (y/n) = N
  6. Would you like this controller to use any components? (y/n) = N
  7. Would you like to use Session flash messages? (y/n) = Y
  8. Press Enter all the way

Generate View Codes: Press V

  1. Choose 1. People
  2. Press enter all the way

Go to: http://localhost/RegistrationPersons/People

and your done! You may now create, edit, delete and view all persons! All of these generated by the bake command.

Here is the actual source code! Enjoy!

6 thoughts on “cakePHP – Registration Application

  1. If you collect all of the bananas and jump through the flaming ring as you bounce, a large banana bunch will appear at
    the end in the air. Tours will resume after the
    busy holiday season, beginning Thursday January 2nd
    at 6 p. If you’re a nonprofit advocating for the homeless,
    tell your prospects how they can gather goods or support services for the homeless in their own community.

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 )

Twitter picture

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

Facebook photo

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

Google+ photo

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

Connecting to %s