Jump to content

Loading dynamic modules in public directories


pdeman2

Recommended Posts

Okay, so I've developed a number of misc PHP extensions for my own use, but right now I'm working on one designed for larger PHP project.  I need this extension to be placed in the document root with the rest of the PHP scripts.  It cannot be placed in the PHP extension directory.  Everything that I've read thus far states that this is possible.  The only problem is, I can't figure out how.  Obviously this type of module needs to be dynamically loaded, so I've tried all sorts of different ways of using dl() to load the DSO file, but it always looks for the file in the PHP extensions directory.

 

Any one know the solution?

 

Thanks.

Link to comment
Share on other sites

Everything that I've read thus far states that this is possible.

 

Everything like what? The dl() manual sure doesn't sound like it....

 

The directory where the extension is loaded from depends on your platform:

 

Windows - If not explicitly set in the php.ini, the extension is loaded from c:\php4\extensions\ by default.

 

Unix - If not explicitly set in the php.ini, the default extension directory depends on

 

    * whether PHP has been built with --enable-debug or not

    * whether PHP has been built with (experimental) ZTS (Zend Thread Safety) support or not

    * the current internal ZEND_MODULE_API_NO (Zend internal module API number, which is basically the date on which a major module API change happened, e.g. 20010901)

 

Taking into account the above, the directory then defaults to <install-dir>/lib/php/extensions/ <debug-or-not>-<zts-or-not>-ZEND_MODULE_API_NO, e.g. /usr/local/php/lib/php/extensions/debug-non-zts-20010901 or /usr/local/php/lib/php/extensions/no-debug-zts-20010901.

Link to comment
Share on other sites

From the PHP article at http://www.php.net/manual/en/zend.using.php

Warning

 

For security reasons, you should not put your dynamic modules into publicly accessible directories. Even though it can be done and it simplifies testing, you should put them into a separate directory in production environments.

 

Granted, this does say you shouldn't do it, the point is that you can.  Also, I know I remember using a PHP optimizer that worked exactly like this.

Link to comment
Share on other sites

I would be pretty careful using the dl() function too..... From the man.

 

    Note:  As of PHP 5, the dl() function is deprecated in every SAPI except CLI. Use Extension Loading Directives  method instead.

 

    Note: Since PHP 6 this function is disabled in all SAPIs, except CLI, CGI and embed.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.