php - correct path files to use in constants so it can be used on any server -


i have small project guess applies size. since have 2 classes think autoload overkill , not relevant here.

what trying achieve if need transfer server or folder compatible , wont need me having edit bunch of links throughout site working.

so have file constants called config.php put in classes folder

define('const_int_path', $_server['document_root']); define('const_root_path', 'http://www.mysite.com'); define('const_project_path', const_root_path.'/website');  define("const_image_path", const_project_path.'/images/'); define("const_classes_path", const_project_path.'/classes/'); define("const_include_path", const_project_path.'/includes/'); define("const_js_path", const_project_path.'/js/'); define("const_css_path", const_project_path.'/css/'); 

so root of project i.e var/www equivilant www.mysite.com , subfolder of website var/www/website i.e www.mysite.com/website

to honest im bit lost, in parts using const_int_path works fine, other places have use const_project_path , use full url path. think latter possibly better option not sure.

is there better way works in cases

i use now:

include const_include_path.'header.php'; include const_include_path.'footer.php'; <img src="<?php echo const_project_path;?>logo.png" /> 

so question 1 of these right 1 use or there better method

define('const_int_path', $_server['document_root']); define('const_root_path', 'http://www.mysite.com'); define('const_project_path', const_root_path.'/website'); 

i'm seeing weird issues includes not loading though if echo out include , paste in url can see im hoping might because method im using flawed

for example if use:

include 'includes/header.php'; 

that works fine if do:

include 'http://www.mywebsite.com/website/includes/header.php'; 

it wont work though know correct path. i'm guessing need drop http:// route , path different way

ok got working, method might not achieve want long term seems working. dont quite understand why yet.

if use in config file:

define('const_root_path', $_server['request_uri']); define('const_project_path', dirname(__file__));  define("const_image_path", const_root_path.'/images'); define("const_classes_path", const_project_path.'/classes'); define("const_include_path", const_project_path.'/includes'); define("const_js_path", const_root_path.'/js'); define("const_css_path", const_root_path.'/css'); 

the weird thing const_project_path works fine classes , includes not work js , css files reason. though folders in same directory, using const_root_path uses $_server['request_uri'] makes css , js work, returns /website instead of var/www/website/


Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -