Re: "Namespace polution" in includes

From: Date: Fri, 18 Jan 2002 14:44:06 +0000
Subject: Re: "Namespace polution" in includes
References: 1 2 3 4 5  Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-3984@lists.php.net to get a copy of this message
El vie, 18-01-2002 a las 15:04, Sebastian Delmont escribió: > > "Alexander Merz" <alexander.merz@s1999.tu-chemnitz.de> wrote in message > news:001c01c19ff8$b36793a0$0200a8c0@alex... > > > In my case, this "bug" is definetively a show-stopper... I'm not going > to > > > use PEAR if it can clash with my current or existing files... > > > It is a show stopper, if this problem occours, but not PEAR specific in > any > > way. With this opinion, you never could use any php scripts or > applications > > from other people. > > No. The difference here is that other people scripts are installed by hand > one by one, instead of being included PHP by default. This is not true. PHP doesn't put PEAR in the include path by default, you have to add it manually. > > PHP implements the include or require like other languages, the problem is > > still a problem since programing languages supports more the one standard > > include dir (>15 years) > > I completely agree with you on this. Just look at all the options in > "configure" scripts for C programs (like PHP itself) > > But PEAR pretends to be the "standard library" (i.e. libc) in a language > that doesn't has separate ways to include standard and non standard files > (i.e. #include <...> vs. $include "..."). > > And to do so without having a simple way of distiguishing between the system > files and your own is calling for trouble. > > As somebody else said on this thread, PHP 5 might be around the corner, but > that doesn't mean everybody will stop using PHP 4 (or 3, for that matter).. > > PEAR is currently migrating to a new directory structure (as in /pear/ > instead of /php4/pear/)... why not do the change to a root "PEAR" directory > right now? > This migration only affects how to place pear components in the CVS repository. It has nothing to do with where those files are installed (I redirect you to the FAQ for more info on this). I understand that this could be a problem, but is not a common problem (only affects few people). I have more than 150 files in my include path and never get any clash with PEAR files. Right now we would disturb so much people for addressing the problems of a few. Anyway here I put a list of possible solutions: 1) PHP "filespaces". A php.ini directive to define that "filespaces", something like: filespace = "pear:/path/to/pear" filespace = "mine:/path/to/my_include" Or a PHP function to set this: <?php define_filespace('pear', '/path/to/pear'); ?> And in your code: <?php require ('PEAR.php', 'pear'); // (file, space) ?> 2) Change PEAR path. This is, for example install pear files in: /usr/lib/php/PEAR and set the include path to point /usr/lib/php. In your code and all the PEAR classes: <?php require 'PEAR/PEAR.php'; ?> 3) Use a PEAR constant and fixed paths. In your code: <?php // This would be a requirement define ('PEAR_BASE_DIR', '/path/to/pear/'); require PEAR_BASE_DIR . 'PEAR.php'; ?> and change all classes to use internally this PEAR_BASE_DIR 4) Invent our "require_pear" function. <?php // Required to define the function and set the internal paths require '/path/to/pear/PEAR.php'; require_pear('DB.php'); ?> Just some ideas, Tomas V.V.Cox

« previous php.pear.dev (#3984) next »