Reputation: 1709
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 !
Upvotes: 0
Views: 20576
Reputation: 20726
another simple way, set an constant in your initialize.php
// Assign file paths to PHP constants
// __FILE__ returns the current path to this file
// dirname() returns the path to the parent directory
define("PRIVATE_PATH", dirname(__FILE__));
define("PROJECT_PATH", dirname(PRIVATE_PATH));
define("PUBLIC_PATH", PROJECT_PATH . '/public');
Upvotes: 0
Reputation:
Yes, u need to define a constant. And its very straight forward. Here you go -
define('UPLOADPATH','/work/images/');
where, UPLOADPATH is the name of a constant. (you can give a name of your choice) and, following that, is the path.
In my case it was in C drive under wamp, www folder. Hence i have only provided path inside www
Upvotes: 0
Reputation: 11
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/
Upvotes: 0
Reputation: 4822
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";
Upvotes: 9
Reputation: 12362
I think ,in case of XAMPP (working locally) the $_SERVER['DOCUMENT_ROOT'] should return you "C:/xampp/htdocs/application/"
Upvotes: 0