cakephp - how to define cake php helpes correctly

45 Views Asked by At

I have an ItemsController which extends AppController. To handle my site menu, I used a menuhelper. However, I saw in the documentation that you have to add your helpers in an array in your controller (AppController):

public $helpers = array('Form', 'Html', 'Menu');

The weird thing is that I forgot it and my menu worked anyway. Also, you always have to add Form and Html extra to the array because otherwise they don't work anymore. However, when I do something like this in my AppController, my form helpers still work:

public $helpers = array('Menu');

So it seems that whatever I do, it still works, but I don't get why and I don't like automatic "magic" :)

Is there something I am missing in the docs?

1

There are 1 best solutions below

2
On

Since 2.x you don't "need" to specify app or core helpers. Those are lazyloaded automatically.

You only need to specify plugin helpers manually.

That said I personally still always describe what helpers I use, just to be consistent with the plugin ones.