Re: "Namespace polution" in includes
| From: | Sebastian Delmont | Date: | Fri, 18 Jan 2002 16:42:01 +0000 |
| Subject: | Re: "Namespace polution" in includes | ||
| References: | 1 2 | Groups: | php.pear.dev |
| Request: | Send a blank email to pear-dev+get-3987@lists.php.net to get a copy of this message | ||
I must apologize for my strong statements.
It's just that it pisses me to see a problem that has a really simple
solution. If PEAR would have had used a "base" directory from the beggining,
it would have been much, much better.
But simple solutions are usually the hardest to spot. And it's even worse
when the problem doesn't affect everybody.
I agree that simply changing the standard to use a base directory could
wreck havoc in the installed user base. And yes, I didn't give it that much
thought.
I'm glad to hear PEAR won't be installed automatically.
Now, with another possible solution:
Writting a PHP (or Perl) script that prefixes every include/require/*_once
statement with "PEAR/" (or any other prefix) is a pretty simple task (except
when the statement uses a variable, but more on the next paragraph).
This script could be used on the user files, or on PEAR files. It is more
probable to have "variable includes" on the user side. On the PEAR side, it
can be take care of with the coding standards.
And if I'm correct, PEAR will use a "program" (or page) to install new
packages.
How hard would it be to have the PEAR installer process all PEAR modules to
use the same prefix? The default will be <blank>, of course, so existing
users need not to worry. It's value can be defined on php.ini (pear.prefix?)
so PEAR modules that need to use variable includes can take it into account.
To make the "prefixer script" even easier to write (and more foolproof), we
could create a "pear_require" statement, and use it in all "new /pear/"
modules. Doing the change to existing files is not too much work.
When PHP5 comes along, the prefix can be changed to "pear:", so it also
gives us a way to use namespaces in the future without changing the code (at
least without having to change it again).
Comments?