[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: PHP application packaging policy/best practice?

[No Cc please, as per list policy]

On Wed, Jan 12, 2005 at 10:16:43AM +0100, Pierre Habouzit wrote:
> Le Mer 12 Janvier 2005 01:31, Matthew Palmer a ?crit :
> > So you patch libfile2.php to require_once 'mylib/libfile1.php'
> > instead of just 'libfile1.php'.
> oh and btw, the suggestion I did is better (IMHO) :
> replace require_once 'libfile.php'; with
> require dirname(__FILE__).'/'.'libfile1.php';
> because you are robust to _any_ mess done by the user with the 
> include_path (for a zero cost). You even not assume that /usr/share/php 
> is in the include_path.

But it has two giant downsides:

1) It's ugly as all hell; and

2) Once people start getting into that habit, they forget all about other
libraries, and where they might be, and start complaining bitterly and/or
bundling other peoples' libraries into their libraries, which creates a

There's also the issue of how to get to the library in the first place from
your application -- you then either need to hard-code the path somewhere in
your app (which, if you do, I *will* beat you with a stick) or you're back
to needing the include_path, which means that all of your dirname() magic
isn't needed anyway.

Oh, another useful tidbit -- file namespaces are useful. 
library/libfile1.php isn't very likely to conflict with another
library/libfile1.php that someone wants to install, whereas libfile1.php
could very well conflict.

- Matt

Attachment: signature.asc
Description: Digital signature

Reply to: