Overcome Common Beginner’s Hurdles with CakePHP Development

You develop sites and most of the times you find tricks to do things faster and with better control ever than before. But this happens only with time when you gain some experience working on a web technology. You can think of many situations where you must have not known what you should do to make things right as a beginner. As a CakePHP newbie, these points will help you overcome common hurdles you face as a beginner:

Beginners Cakephp Hurdles

Incorrect Filenames

As a beginner, you would face this problem quite regularly. Whether to write a filename with or without an‘s’ at the end is quite a task for you at the starting. To avoid this mistake to appear again and again, try to stick to the basic rules. Always remember two things. Firstly, controllers are always plural. For e.g. users_controller.php. And secondly, Models are singular, e.g. user.php.

‘echo’ in views

If you are not using echo, your program can skip to have form helper while you are building a form and this can be quite bothersome for you as a newbie.
Avoid this little hurdle by just adding this small piece of code to your plain HTML code:


<?php echo $some[‘array’]; ?>


Instead of writing


echo ‘<div>’;

echo $some[‘array’];

echo ‘</div>’;

This does not just help you get the required help module right in place but also helps you increase productivity by helping you take charge of IDEs better and get better response with codeformatting.

Correct paths to images

HtmlHelper needs to be implemented and used well to avoid problems fetching images from their sources. It will create the right path for your picture to help it reach the destination accurately even if the site structure in not placed properly. Or else, the time you use standard html img tag, it could contain some issues with the view because of which problem in viewing image could appear.

Unexpected results in ajax calls

One of those painful ones to have. You see all logics placed right but still things are not working as they should. You can face it most of the times creating a new method if you don’t check your debug level.

Putting this code would help and lot and will save you from wasting too much of time:

function foobar()  {

// somthing happens here


Nice urls

Try using url names that the database and name conventions suggest and not the ones that attract you. Just make things work out first and then go for nice urls. Just don’t waste your time thinking about the appealing names at first. Just continue with the flow. Once you are done with coding routes, it will automatically do it for you when you build it with the help of HtmlHelper.

I also used to put the query in the controller as it seemed quite easy and didn’t trouble me in anyway, as happens with most of them in the beginning. But steadily as I turned mature with CakePHP development, I came to know that this will not keep the structure clean. To have everything right in control put everything in the model to which it belongs and acquire data from there. This way the controller will stay lean and that will help you keep everything organized, most easily!