6

I am building windows .cmd files which will run demo examples of our PHP tools. I have a "catch-22" problem, I need to determine how to find the PHP installation path from a Windows .cmd script without using PHP. EasyPHP does not install itself into the windows path so that is why I can't use PHP.exe.

So stated in a different way I would like to determine the information that the getcwd() command returns in php but without using PHP. So "how" does getcwd reference what information from where to determine the working php directory?

I have not been able to find file(s) or? with all the text data I might then search for which would be the referenced source of the php path information.

I did find this file ... c:\EasyPHP-5.3.8.1\conf_files\httpd.conf ${path} is mentioned (see file text below) but I can't find where this ${path} is defined, where is ${path}defined for php? NOTE: that ${path} in PHP is not the same as the windows $path environment variable! there are NO windows environment variables present which contain EasyPHP information!

partial file text .... # IMPORTANT # ${path} is used to specify EasyPHP installation path . .(text lines omitted) . # DocumentRoot: The directory out of which you will serve your # documents. By default, all requests are taken from this directory, buet # symbolic links and aliases may be used to point to other locations. # DocumentRoot "${path}/www"

Ron Whites
  • 1,721
  • 3
  • 12
  • 8

3 Answers3

2

Turns out there is no "universal" good way to determine what document root path is for the active PHP server. It's a catch-22 you can determine the value by running php in the web browser.

FYI I have designed a .cmd script that asks for the document root path, it's unfortunate I must ask and trust the user but that is the way it is!

Ron Whites
  • 1,721
  • 3
  • 12
  • 8
1

IF the php directory is in the PATH then you can see if the directory is there (in command line it is %PATH%).

Victor
  • 1,655
  • 9
  • 26
  • 38
1

I'm not familiar with writing command line scripts under windows, but for finding files you can use:

dir c:\ /s /b | find "php.exe"
dev-null-dweller
  • 29,274
  • 3
  • 65
  • 85
  • I know this help find files and their contents and this is part of the method I will need to use. But how could one find the docuemt root this way? The php folder could be named anything and be anywhere ... and what would be the algorithm for determining the document root from where php.exe is? real question is how do php systems (easyphp zend or?) know where the document root is? what is the code behind getcwd() what does it reference? – Ron Whites Nov 06 '11 at 20:45
  • I thought that you are looking for php executable to run some file. Finding document root have nothing to do with php, it is dependent to web server configuration. I think the easiest way would be to prompt user to enter this path, since there are to many possibilities to look for. – dev-null-dweller Nov 06 '11 at 20:56
  • yes I need to find the document root, to install a php web program. The example then runs an example web page there. FYI we have tools which are built out of our unique compiler technology which do ... testcoverage, time profiling, obfuscation, and searches by language not just by text, etc. Workimg on examples of use for things which can be somewhat complicated to setup. – Ron Whites Nov 06 '11 at 23:46