Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to load an extension from PHP cli interface, without modify the ini file?

Tags:

php

I checked man php and output of php -h, but I didn't seem to find such thing.

But I remember seeing it somewhere, you could do something like php -Xabc.so script.php to load an extension temporarily.

Anyone know that?

like image 320
daisy Avatar asked Oct 10 '12 03:10

daisy


People also ask

Where do I put PHP INI extension?

Go to your php. ini file and add the following line: extension=<extension_name>. dll. To verify that the extension was loaded properly, go to Setup | Extensions and locate the extension from the list.

How do I show PHP extensions?

If your server only has a single PHP version installed, you can run this PHP command anywhere, and it will give you the same list of modules. The general command we will be using is php -m. This command will give you the full list of installed PHP modules/extensions.

What is PHP extension?

php file extension refers to the name of a file with a PHP script or source code that has a ". PHP" extension at the end of it. It's similar to a Word file with a . doc file extension.


1 Answers

Loading a regular extension via CLI is done with:

php -dextension=abc.so myfile.php

If your extension is not in the default path you can provide an absolute path as well:

php -dextension=/path/to/abc.so myfile.php

To load a Zend extension, it'd advisable to always pass an absolute path:

php -dzend_extension=/path/to/abc.so myfile.php
like image 146
Ja͢ck Avatar answered Oct 21 '22 11:10

Ja͢ck