phpcakephpcakephp-2.0cakephp-helper

Organizing helpers in sub-directories


I am new to CakePHP and I had trouble organizing my helper files. I searched through the web and doesn't seem to find an answer for this.

I have no problem using the helpers if I put them under app/Views/Helpers/test.

But when I put it under app/Views/Helpers/Global/test,

and

class AppController extends Controller {

public $helpers = array('Form', 'Html', 'Js', 'Time', 'Text', 'Session','Global/testHelper');

I get a "Cannot redeclare class testHelper"

Does anyone have any idea?


Solution

  • The best way to organize and package your code is using Plugins.

    You cannot have subfolders under your app's Helpers directory. But you can use App::build() to specify alternate locations for your helpers.