views:

54

answers:

4

Hello ! I know it may be simple question to all experienced developer.. I have trapped with the problem that how to set the path in bootstrap file

like ......

when i work on local ... i use this path

 $filenam = "C:/xampp/htdocs/application/public/pdf_profile/$pdfname.html";

when i upload this particular file... i need to make change ..in this path ..like this

$filenam = $_SERVER['DOCUMENT_ROOT']."/public/pdf_profile/$pdfname.html"; 

i want to know is there any solution to prevent change again n again .. like any change in bootstrap file .. how to define path in this way that i have no need to worry about path.. at time of local or live Basically am working with zend

thanks in advance !

A: 

one simple way, set an constant in your index.php

define('PUBLIC_PATH', realpath(dirname(__FILE__)));
ArneRie
but how shoul i use this .. in the file ?i meant plz elaborate it
Richa
A: 

I think ,in case of XAMPP (working locally) the $_SERVER['DOCUMENT_ROOT'] should return you "C:/xampp/htdocs/application/"

Ankit Jain
nah ..its not returning .. local path ..thats the main problem :(
Richa
+1  A: 

Define a constant in your index.php

define('BASE_PATH', realpath(dirname(__FILE__)));

You can use this constant like so everywhere in your application

$filename = BASE_PATH . '/pdf_profile/' . $pdfname . '.html";
Benjamin Cremer
A: 

If you use Zend_Tool to generate your project, it should automatically add code in your index.php that defines a constant called APPLICATION_PATH which is an absolute path to your application folder in a ZF project.

All files related to a project should stay under the same tree, you should put all your projects into subfolders of your document root and create virtual hosts.

C:/xampp/htdocs/
    myapp/
        application/
        data/
        library/
        public/
        tests/
    anotherapp/
        application/
        data/
        library/
        public/
        tests/
Andrew Cobby