Welcome Guest, Not a member yet? Register   Sign In
Common constants file for multiple projects
#1

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!
Reply
#2

Place the file in an include folder and then include it in your projects.
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply
#3

(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
Reply
#4

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.
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply
#5

(05-23-2016, 07:54 AM)InsiteFX Wrote: 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.

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?
Reply
#6

(This post was last modified: 05-23-2016, 08:46 AM by InsiteFX.)

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.
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply




Theme © iAndrew 2016 - Forum software by © MyBB