Define absolute / relative directories for CMS in PHP

0

I am re-studying PHP, proposing to make my own CMS. I already have a lot of things: modular system, login, etc., but some time ago I'm standing in a seemingly minuscule problem: the paths! Use WAMP in development and CPanel in semi-production tests (different systems on purpose) and mess with the "c: / a / a" and the "/ a / a /". Yes, it is partially solved using relative urls, but since I am in development, changing the directory tree becomes a problem. As I do? Armo a constant? Armo a variable? How do I make it independent if the CMS works on Windows or * NIX?

    
asked by Pato 22.09.2018 в 21:06
source

1 answer

0

After posting, I started thinking and it's really simple. As all the pages or parts of them (navs, headers, footers) charge them through require/include as needed, it was enough for me to formulate in an external php (I used the one from where I connect and charge the databases) the following constants:

define('PATH', '/');
define('CSS', PATH . 'mi/directorio/css/');
define('JS', PATH . 'mi/directorio/js/');
define('IMG', PATH . 'mi/directorio/img/');
...............

And from the pages and / or parts of it "I call" each of the constants =)

    
answered by 22.09.2018 в 22:19