문제

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?

도움이 되었습니까?

해결책

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.

다른 팁

The error is pretty self explanatory. You can not literally call your helper TestHelper, as that name is already taken by the CakePHP Test Suite (defined in lib/Cake/Test/Case/View/HelperTest.php).

Just name your helper something else and you should be fine.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top