where to define constants in cakephp

后端 未结 3 1981
故里飘歌
故里飘歌 2021-02-07 09:14

In which file should I define application-wide constants that are specific to my cakephp app?

3条回答
  •  日久生厌
    2021-02-07 09:28

    There is a another way to set constants in external file except doing it in long files like bootstrap (When it's doesn't effect on Behaviors like editable Pdf constants).

    It could be retrieved from view, controller or model:

    Configure::load('PDF_CONSTANT_FILE'); 
    echo THE_CONSTANT;
    
    // PDF_CONSTANT_FILE set in  app/config/PDF_CONSTANT_FILE.php
    

    Adding $config=array(); to PDF_CONSTANT_FILE.php file at start is necessary.

    Just for general benefit.

提交回复
热议问题