![]() |
Common constants file for multiple projects - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Development (https://forum.codeigniter.com/forumdisplay.php?fid=6) +--- Forum: CodeIgniter 3.x (https://forum.codeigniter.com/forumdisplay.php?fid=17) +--- Thread: Common constants file for multiple projects (/showthread.php?tid=65155) |
Common constants file for multiple projects - slipdiegoknot - 05-06-2016 Hi friends, I have many projects in my htdocs folder. These projects have many common constants and are repeated in each constant folder, I want to have a common constant file for all the projects to use. How can I achieve so? Thanks! RE: Common constants file for multiple projects - InsiteFX - 05-06-2016 Place the file in an include folder and then include it in your projects. RE: Common constants file for multiple projects - slipdiegoknot - 05-23-2016 (05-06-2016, 02:34 PM)InsiteFX Wrote: Place the file in an include folder and then include it in your projects. Thanks! I put a regular php file in the config folder and in the rest of my projects (begining of the constant file) I put this line PHP Code: include_once((isset($_SERVER['DOCUMENT_ROOT']) ? $_SERVER['DOCUMENT_ROOT'] : 'C:/xampp/htdocs')."/schoowl/application/config/constantes_globales.php"); It works fine. The only drawback is that autocomplete doesn't work in the other projects, I use zend studio 12.5 RE: Common constants file for multiple projects - InsiteFX - 05-23-2016 Try it this way and see if autoload will work: PHP Code: include_once(APPPATH."config/constantes_globales.php"); This means that index.php has to run before calling the include file. RE: Common constants file for multiple projects - slipdiegoknot - 05-23-2016 (05-23-2016, 07:54 AM)InsiteFX Wrote: Try it this way and see if autoload will work: I guess my code does run after the index.php because I placed the include in the constant files and the constant files load after the index file right? RE: Common constants file for multiple projects - InsiteFX - 05-23-2016 Everything loads from the index.php, index.php is like CI front controller. I place all my constants at the bottom of CI's constants.php file this way there all in one place. |