# Bug #54514

- Thread: https://externals.io/message/56820
- Original archive: https://news-web.php.net/php.internals/56820
- Started by Sebastian Bergmann on 2011-12-07T07:22:27+00:00
- Messages: 11
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #56820 — Sebastian Bergmann — 2011-12-07T07:22:27+00:00

URL: https://externals.io/message/56820#56820

Can somebody look into https://bugs.php.net/bug.php?id=54514 please?
  This causes issues for CLI tools implemented in PHP that are invoked
  through Apache Ant, for instance, and need to know the PHP interpreter
  that is running them.

  See https://github.com/sebastianbergmann/phpunit/issues/432 for an
  example of how this affects PHPUnit.

-- 
Sebastian Bergmann                    Co-Founder and Principal Consultant
http://sebastian-bergmann.de/                           http://thePHP.cc/

---

## #56821 — Ferenc Kovacs — 2011-12-07T08:03:43+00:00

URL: https://externals.io/message/56820#56821 · In reply to: #56820

On Wed, Dec 7, 2011 at 8:22 AM, Sebastian Bergmann <sebastian@php.net>wrote:

>  Can somebody look into https://bugs.php.net/bug.php?**id=54514<https://bugs.php.net/bug.php?id=54514>please?
>  This causes issues for CLI tools implemented in PHP that are invoked
>  through Apache Ant, for instance, and need to know the PHP interpreter
>  that is running them.
>
>  See https://github.com/**sebastianbergmann/phpunit/**issues/432<https://github.com/sebastianbergmann/phpunit/issues/432>for an
>  example of how this affects PHPUnit.
>
> --
> Sebastian Bergmann                    Co-Founder and Principal Consultant
> http://sebastian-bergmann.de/                           http://thePHP.cc/
>
> --
> 
> 
>
>
+1, I also seen workarounds of this missing functionality in the symfony2:

https://github.com/symfony/Process/blob/master/PhpExecutableFinder.php
https://github.com/symfony/symfony/blob/master/tests/Symfony/Tests/Component/Process/PhpExecutableFinderTest.php

 `PHP_BINDIR` is available, and from a quick test, $_SERVER['_'] has the path
for the php binary also (only tested it on linux, cli).

-- 
Ferenc Kovács
@Tyr43l - http://tyrael.hu

---

## #56822 — Laruence — 2011-12-07T08:16:10+00:00

URL: https://externals.io/message/56820#56822 · In reply to: #56820

HI,
   I am looking at it :)

   how about add a `PHP_BINARY` into $_SERVER,  but not register as a constant?

thanks,


>  Can somebody look into https://bugs.php.net/bug.php?id=54514 please?
>  This causes issues for CLI tools implemented in PHP that are invoked
>  through Apache Ant, for instance, and need to know the PHP interpreter
>  that is running them.
>
>  See https://github.com/sebastianbergmann/phpunit/issues/432 for an
>  example of how this affects PHPUnit.
>
> --
> Sebastian Bergmann                    Co-Founder and Principal Consultant
> http://sebastian-bergmann.de/                           http://thePHP.cc/
>
> --
> 
> 
>



-- 
Laruence  Xinchen Hui
http://www.laruence.com/

---

## #56823 — Pierre Joye — 2011-12-07T08:41:10+00:00

URL: https://externals.io/message/56820#56823 · In reply to: #56822

hi Laruence,


> HI,
>   I am looking at it :)
>
>   how about add a `PHP_BINARY` into $_SERVER,  but not register as a constant?

and why not?

Cheers,
-- 
Pierre

@pierrejoye | http://blog.thepimp.net | http://www.libgd.org

---

## #56824 — Laruence — 2011-12-07T08:44:15+00:00

URL: https://externals.io/message/56820#56824 · In reply to: #56823

HI:

1.  the `PHP_BINARY` is only make sence in cli sapi
2.  if the use script, by chance,  has codes:  define("PHP_BINARY",
***) will trigger error


thanks


> hi Laruence,
>
> 
> > […]
>
> and why not?
>
> Cheers,
> --
> Pierre
>
> @pierrejoye | http://blog.thepimp.net | http://www.libgd.org



-- 
Laruence  Xinchen Hui
http://www.laruence.com/

---

## #56825 — Hannes Magnusson — 2011-12-07T08:48:59+00:00

URL: https://externals.io/message/56820#56825 · In reply to: #56824

> HI:
>
> 1.  the `PHP_BINARY` is only make sence in cli sapi
> 2.  if the use script, by chance,  has codes:  define("PHP_BINARY",
> ***) will trigger error
>

Constants starting with PHP_ are reserved by PHP.
This has come up several times before and we agreed a `PHP_BINARY` 
constant made the most senes.

"The problem" with this feature was when we backtrack binary to load
the php.ini file, it was to early in the startup to be able to
register a constant, variable or whatever..

-Hannes

---

## #56826 — Pierre Joye — 2011-12-07T08:49:14+00:00

URL: https://externals.io/message/56820#56826 · In reply to: #56824

> HI:
>
> 1.  the `PHP_BINARY` is only make sence in cli sapi

It can be the module as well.

However phpUnit has a design mistake here by not allowing to set the
php exec binary path to run the tests. But that's another topic :)

Cheers,
-- 
Pierre

@pierrejoye | http://blog.thepimp.net | http://www.libgd.org

---

## #56827 — Patrick ALLAERT — 2011-12-07T08:56:15+00:00

URL: https://externals.io/message/56820#56827 · In reply to: #56820

2011/12/7 Sebastian Bergmann <sebastian@php.net>:
>  Can somebody look into https://bugs.php.net/bug.php?id=54514 please?
>  This causes issues for CLI tools implemented in PHP that are invoked
>  through Apache Ant, for instance, and need to know the PHP interpreter
>  that is running them.
>
>  See https://github.com/sebastianbergmann/phpunit/issues/432 for an
>  example of how this affects PHPUnit.
>
> --
> Sebastian Bergmann                    Co-Founder and Principal Consultant
> http://sebastian-bergmann.de/                           http://thePHP.cc/
>
> --
> 
> 
>

 `PHP_BINDIR` . "/php" ?

Patrick

---

## #56828 — Laruence — 2011-12-07T10:38:50+00:00

URL: https://externals.io/message/56820#56828 · In reply to: #56827

Hi:
  what if I rename the php to something else :)

thanks


> 2011/12/7 Sebastian Bergmann <sebastian@php.net>:
> > […]
>
> `PHP_BINDIR` . "/php" ?
>
> Patrick
>
> --
> 
> 
>



-- 
Laruence  Xinchen Hui
http://www.laruence.com/

---

## #56835 — Derick Rethans — 2011-12-07T17:45:36+00:00

URL: https://externals.io/message/56820#56835 · In reply to: #56820

>  Can somebody look into https://bugs.php.net/bug.php?id=54514 please?
>  This causes issues for CLI tools implemented in PHP that are invoked
>  through Apache Ant, for instance, and need to know the PHP interpreter
>  that is running them.
> 
>  See https://github.com/sebastianbergmann/phpunit/issues/432 for an
>  example of how this affects PHPUnit.

I've code to do this on Windows:

#if WIN32
PHP_FUNCTION(get_php_process)
{
    char filename[1024];
    GetModuleFileName(NULL, filename, 1024);
    RETURN_STRING(filename, 1)
}
#endif

On linux, we currently do:

$pid = `getmypid()`;
$process = "/proc/{$pid}/exe" 

cheers,
Derick

-- 
http://derickrethans.nl | http://xdebug.org
Like Xdebug? Consider a donation: http://xdebug.org/donate.php
twitter: @derickr and @xdebug

---

## #56843 — Pierre Joye — 2011-12-07T21:48:56+00:00

URL: https://externals.io/message/56820#56843 · In reply to: #56835

hi Derick,

yes, that's what is done in the ini detection implementation, which is
now used in main/.

The only remaining related bug I like to fix is ot PHP_BINDIR, which
is now set at compile time. We could do the same thing than now
PG(PHP_BINDIR).


> 
>
> > […]
>
> I've code to do this on Windows:
>
> #if WIN32
> PHP_FUNCTION(get_php_process)
> {
>    char filename[1024];
>    GetModuleFileName(NULL, filename, 1024);
>    RETURN_STRING(filename, 1)
> }
> #endif
>
> On linux, we currently do:
>
> $pid = `getmypid()`;
> $process = "/proc/{$pid}/exe"
>
> cheers,
> Derick
>
> --
> http://derickrethans.nl | http://xdebug.org
> Like Xdebug? Consider a donation: http://xdebug.org/donate.php
> twitter: @derickr and @xdebug
>
> --
> 
> 
>



-- 
Pierre

@pierrejoye | http://blog.thepimp.net | http://www.libgd.org
