Re: location of the PHP executable

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



your script should try it's best to find the executable, on failure
you might consider having it mail an error to you so at least you
can pre-empt the client with regard to getting things working.

most windows machines will probably have there php binary at:

	$_ENV['PHPRC'].'php.exe'

variations on the exe name can be (IIRC):

	'php-win.exe'
	'php-cli.exe'

I think you can be pretty sure about $_ENV['_'] on *nix
systems.

another to consider is a simple installer which tries to
find the exe and on failure offers the user a prompt to say where it
is .. that info can then be stored for use at a later date.

Mattias Thorslund wrote:
> Jochem Maas wrote:
> 
>>> have you tried looking for this info you want?
>>>   
>>   
> 
> Yup, but the manual seems kind of "light" on the subject.
> 
> 
>>> I can't say for sure if it always exists but on the few boxes
>>> I tried I found and entry in both $_SERVER and $_ENV:
>>>
>>> "_" => '/usr/bin/php'
>>>   
>>   
> 
> I found these in $_ENV and $_SERVER, on Linux. I don't have handy access
> to a working Windows installation, yet it needs to work on Windows as well.
> 
> If it really does exist on Windows, this might be the ticket, otherwise
> a partial solution for Linux only.
> 
> 
>>> but that was only on linux.
>>> on windows (where my php cli install is a bit borked),
>>> I didn't find it but I did find "PHPRC" which points to
>>> the directory that the php executable lives in.
>>>   
>>   
> 
> That's at least something. If someone could confirm, that would be great.
> 
> I used the following command (at the command-line) to check the contents
> of $_SERVER:
> 
> php -r 'print_r($_SERVER);'
> 
> Obviously, $_ENV can be checked similarly.
> 
> 
>>> these maybe of some use.
>>>   
>>   
> 
> Yes very useful, thanks.
> 
> 
>>> then again what ever it is your trying to do with the php script
>>> you seem to need to run inside another instance of php could probably
>>> be run within the context of the calling script - if you run it inside
>>> a function you can stop any kind of variable scope clashes (assuming there are
>>> no symbol name clashes [e.g. duplicate functions/classes]):
>>>
>>> function runit()
>>> {
>>> 	include 'myscript.php';
>>> }
>>>
>>> it's just a thought.
>>>   
>>   
> 
> Unfortunately, I think it's not an option in my case. The sub-process I
> run this way are way, way too big to include in the main process.  As
> long as I was just running it on my own systems, it was easy to
> hard-code the location of the PHP executable but now that it's being
> distributed, it needs to "just work"...
> 
> Thanks again,
> 
> Mattias
> 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux