Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP 5.3+ enable_dl not enabling dl()?

I am trying to install a 3rd party PHP extension (.so) into PHP 5.3.6-13 on Ubuntu 11.10 and use it in a web environment. The vendor's documentation suggests using the dl() function to dynamically load the library.

When I try their example code, I find the dl() isn't available (Fatal error: call to undefined function dl()) as dl() function was deprecated in PHP 5.3. But there is an enable_dl config rule in php.ini, and other sources say that I should be able to use dl() simply by changing the php.ini variables (enable_dl=On, safe_mode=Off, not listed in disable_functions) and restarting apache. When I try that, dl() is still undefined.

So I dig into the PHP 5.3 SAPI change notes and find this:

The dl() function is now disabled by default, and is now available only under the CLI, CGI, and embed SAPIs.

Does this mean that dl() is not only "disabled by default" in PHP 5.3+ using a web SAPI, but actually "completely unavailable no matter what I do even with modifying PHP config options"? That's what it appears to me to be since I can't get dl() to work no matter what I tweak.

To clarify: I can modify php.ini and load the extension directly, so this is not a question about how to get the extension working, rather about the function dl() and its state in PHP 5.3+. If it's no longer available under any circumstance I want to be able to tell the vendor, so they can update their documentation. But if it should be available and I'm just missing something, I'd like to hear that too.

like image 602
jonathanm Avatar asked Aug 31 '12 19:08

jonathanm


1 Answers

This function has been removed from some SAPIs in PHP 5.3. -- dl()

So if you have the ini setting enable_dl set to on and it still does not work, then it is disabled in the SAPI you use.

If you wonder which SAPIs are meant, the changelog on that same page is more detailed:

The only SAPIs that allow dl() are CLI and Embed.

You are not using any of these two. Instead use the Extension Loading Directives and you're fine.

like image 70
hakre Avatar answered Oct 05 '22 23:10

hakre