pdeman2 Posted May 31, 2007 Share Posted May 31, 2007 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. Quote Link to comment Share on other sites More sharing options...
trq Posted May 31, 2007 Share Posted May 31, 2007 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. Quote Link to comment Share on other sites More sharing options...
pdeman2 Posted May 31, 2007 Author Share Posted May 31, 2007 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. Quote Link to comment Share on other sites More sharing options...
trq Posted May 31, 2007 Share Posted May 31, 2007 Have you looked at the user comments in the man entry for dl()? There is a function (second from the bottom) that may be of use. Quote Link to comment Share on other sites More sharing options...
pdeman2 Posted May 31, 2007 Author Share Posted May 31, 2007 I must have missed that one. This is very helpful. I'll try it out in a little while. Thanks for the help. Quote Link to comment Share on other sites More sharing options...
trq Posted June 1, 2007 Share Posted June 1, 2007 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. Quote Link to comment Share on other sites More sharing options...
pdeman2 Posted June 1, 2007 Author Share Posted June 1, 2007 Yes, I noticed that a couple days ago. This makes me nervous, but as far as PHP 6 goes, I'll cross that bridge when I come to it. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.