Little Introduction to CakePHP

Hey PHP-Freaks!

Let me show you how to create an Useradministration written in PHP with an MySQL Database running in background in just 2 Minutes. No! That’s no joke! You will be able to add, edit, delete and list Users after using the so called “Cakebaker” - a script which is included in the rapid developer framework Cake-PHP. cakelogo.jpg

Unfortunately I must say that the “installation” of this framework was a little bit tricky. Maybe I will write a short guideance about this in the next view weeks. You should be familiar with the MVC-Design Pattern otherwise the following content will be to hot for you!!SO lets start: After the correct installation of the latest stable version of cakephp you have to create a database with a table, in this case “users”. Please be careful by keeping the conventions of CakePHP. A Table has to be named in plural! The corresponding Model to this table has to be named in singular “User”:class User extends AppModel{var $name = "User";}And thats just the only piece of code you have to write. Save it as user.php in app/models and go to the terminal.In the terminal execute the script cake/scripts/bake.php with your php application. If you have a standart MAMP installation like my system it will be placed in /Applications/MAMP/bin/php5/bin/The whole command should look something like this:/Applications/MAMP/bin/php5/bin/php cake/scripts/bake.php

Now follow the instructions what the script will display and create the whole application under 2 minutes ;-). The script will “bake” you the appropriate views for the different actions (add, edit, etc). cakebaker.png

No take a closer look to the created Controller and the Add-View.Here you can see the created view with all users and the possible actions on the right column.

userlisting.png
And here the Formular to create and update the Users:
edituser.png
Here are some Links and usefull things to get in touch with this great framework: 

2 Responses to “Little Introduction to CakePHP”

  1. Flo Says:

    CakePHP is a very nice framework indeed. Kinda like RoR in PHP. The only gripe I’ve got is the lack of a decent authentication function that supports multiple user levels and permissions. Have you found anything that works?

  2. grobi Says:

    sorry flo not yet. but i will take a look @ this. Probably i will need it in the nex time

Leave a Reply