Bug #77801 [Opn->Ver]: CLI option -z/--zend_extension does not load specified zend extension

From: Date: Fri, 28 May 2021 13:06:29 +0000
Subject: Bug #77801 [Opn->Ver]: CLI option -z/--zend_extension does not load specified zend extension
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-234069@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=77801&edit=1

 ID:                 77801
 Updated by:         cmb@php.net
 Reported by:        smokey101stair at gmail dot com
 Summary:            CLI option -z/--zend_extension does not load
                     specified zend extension
-Status:             Open
+Status:             Verified
 Type:               Bug
 Package:            *General Issues
 PHP Version:        Irrelevant
 Block user comment: N
 Private report:     N



Previous Comments:
------------------------------------------------------------------------
[2021-05-28 13:06:18] cmb@php.net

The problem is that the order of CLI args processing is borked.
The first getopt() (in main()) processes only some of the args,
then SAPI and modules are started up; only afterwards the second
getopt() block (in do_cli()) processes further args (-z plus some
others), and the extension is loaded, but never initialized.

Given that -z is useless, and -dzend_extension= works as expected,
it might be best to just drop the -z arg.

------------------------------------------------------------------------
[2019-03-26 23:31:05] krakjoe@php.net

Also happens in other operating systems ...

The reason -m doesn't show it's loaded is clear, they are different getopt blocks.

But even when you run a script with get_loaded_extensions dump, the zend extension is not loaded
(tested with opcache which registers a module, the module is not registered).

------------------------------------------------------------------------
[2019-03-26 22:48:00] smokey101stair at gmail dot com

Description:
------------
Using the -z/--zend_extension option to load a zend extension when using php from the CLI
doesn't seem to work on Windows. I tested using PHP versions 5.6.40, 7.2.16, and 7.3.3.

In my particular case, I was trying to load xdebug.

php -z <path to xdebug> -m

The above results in no modules listed under [Zend Modules]

php -z <path to xdebug> --re xdebug
php -z <path to xdebug> --rz xdebug
php -z <path to xdebug> --ri xdebug

The above all result in an error stating that xdebug does not exist.

php -d zend_extension=<path to xdebug>

The above can be used as a workaround as it loads the extension as expected.

Please let me know if I can provide any additional information.




------------------------------------------------------------------------



--
Edit this bug report at https://bugs.php.net/bug.php?id=77801&edit=1


Thread (4 messages)

« previous php.bugs (#234069) next »