Hi all, I have a need for a package mechanism like that provided by TCL. We write a lot of code in reusable libraries and often encounter the situation in which an application uses a particular library but requires at least version X or greater.
The require(), require_once(), etc. functionality doesn't provide any version checking facility and I'm not aware of any other such mechanism built into PHP. I played around with the following which kind of emulates the TCL behaviour: In each library I set a variable that contains that file's version number (automatically populated by CVS keyword expansion). I then replaced my require() statements by a customised version which takes version number arguments. So, in my application script I have, for example: require_once("package.inc"); package_require("libraryfile.inc", 1.5, 0); ... And in package.inc I have: function package_require($file, $minVersion, $maxVersion) { require_once($file); // Code to check if $file is within the specified bounds } The obvious (potential) problems with this approach are with respect to scope. Most of the libraries I use contain function and class definitions and I'm not at all sure about the consequences of declaring these from within another function (package_require()). To my surprise, though, it seemed to work. No errors were generated and I could happily use the classes and functions as usual. I'm a little nervous, though, about problems that are not immediately visible. Secondly, there is the problem of global variables. Any variables set in the global scope in the library files are now in the local scope of the package_require() function. I cannot put 'global' declarations for each of these as I would have to know about each and every one of them in advance which prevents it from being a general solution. Does anyone else have some good ideas about this issue? Are there any plans to implement this in PHP itself where it properly belongs? Thanks and regards, Douw. -- Douw Steyn - Visual Information Systems Phone 27-21-4246290, Fax 27-21-4246208, email: [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]