1
votes

Recently I needed to do some modifications to a CakePHP project. Being completely new to Cake I was surprised to see how many helper functions the framework has included.

Of course some of them are really cool as they do all the heavy lifting, but what is the advantage of using e.g. the HTML helper to create markup in a view? I mean there is no difference between the <p> tags I write by hand or let cake print.

Or why should I use the file utility to delete a file? Can't I just use PHP's normal unlink function?

Are there any negative effects of using standard PHP functions instead of the CakePHP functions (besides sometimes more work)?

1
you can replace all of cake with 'normal' php functions. perhaps a framework is not for you.user557846

1 Answers

3
votes

There are some functions in CakePHP that are there mostly for the functionality of the core modules. The file operations are an example. They have been unit tested so the CakePHP developers can use them to do things in their code, and have gifted them to us as users of their framework.

The View helpers are different. The HTML helper does a few things for you that make it a handy tool

  • They allow you to work with array to describe HTML tag attributes. I've used this to store HTML specific attributes far away from the view as settings for something, and it's easy then in the view to create those attributes.
  • They handle Routing of URLs for you. The HTML helper will create <a> links that use your applications routing. Should you change your routing then all your views are updated.

All the other helper classes have similar benefits.