Archive for March 28, 2007

Things you should know about cakePhp

21 things I learned about cakePhp almost covers all the basics to intermediate lessons a beginner should know about.. check them one by one and you’ll surely get some good points even if you have used it for a long time. I did and got a lot of new lessons!

I have some more things to add or comment to.

Easily creating static pages
This is a great solution! if you want to rename it, you can use the route.php to configure the names. example, i have an about page, you can point http://www.example.com/pages/about to http://www.example.com/about.. quite neat. Read this tutorial for more options on how to do it.

Viewing the SQL queries that are running behind the scenes
I use this code to hide and unhide those sql queries (which i really love)

Multiple sources of documentation
Add the bakery to that. More resources here.

Using bake.php
Do try this one, you’ll surely love cakePhp more..

Mind permissions when moving cake around
This is one of the most common error
Warning: file_put_contents(/home/directory/app/tmp/cache/models/default_gcsbox_list) [function.file-put-contents]: failed to open stream: Permission denied in /home/directory/cake/basics.php on line 822

Just do the chmod -R 777 to /app/tmp as suggested.

Creating a controller that uses other models
I use this most of the time but you should also not forget that you can use the $this->Post->User->function();

There is another method where you can use another model in the Model class but can’t find that link yet.. I will update this once i found it.

Call exit() after redirecting
if you are using cakePhp1.2, you do the ffg:

$this->redirect('controller/action', null, true);

According to this post, the latter makes the app testable than using the exit or return. Return would also be a good option but be careful when using it in the beforeFilter(). Read more here.
Some more additional info

  1. Use debug() to display an array covered by the pre tag so you can check the array clearly.
  2. bindModel and unbindModel on the fly. I also found this code very helpful and provide cleaner interface for the controllers

I also notice among my friends that uses xampp, after the installation, the sample page has a very basic html look. You should atleast see the colors of the cakePhp main site to know its really working (aside from the database message). If you experienced this problem, check your Apache configuration. My conf has the ffg codes

<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>

I just change the AllowOverride None to AllowOverride All and things work perfectly.

If you have common things you use that you want to share, please inform me and I’ll be happy to add them to the list..

March 28, 2007 at 3:51 pm 10 comments


Recent Posts

a

 

March 2007
M T W T F S S
« Feb   Apr »
 1234
567891011
12131415161718
19202122232425
262728293031  

Follow

Get every new post delivered to your Inbox.