proposal to remove replacements in PEAR2
| From: | Gregory Beaver | Date: | Fri, 24 Aug 2007 21:48:54 +0000 |
| Subject: | proposal to remove replacements in PEAR2 | ||
| Groups: | php.pear.dev | ||
| Request: | Send a blank email to pear-dev+get-47828@lists.php.net to get a copy of this message | ||
Hi all,
After a lively discussion on IRC, I think we (Helgi, Josh, Chuck, Brett
and I) may have a solution to the conundrum of using replacements in
PEAR2 packages to locate data files and other non-php_dir files.
The proposed solution is to eliminate the configurability of data_dir
(meaning data_dir is always hard-coded at php_dir/data), and to add a
new configurable location called www_dir.
The reasoning behind this change is that data_dir is the only
configuration variable used actively by the run-time programming code to
locate non-PHP files, such as DB_DataObject's .ini files, HTML or JS
files and so on.
It is a best practice to keep all web frontend files in a separate
location from your PHP files, to help avoid potential exploits by
browsing to the library code, and so allowing www_dir to be a separate
location solves this problem. www_dir is intended to make official the
web_dir role created by the pearified.com/Role_Web package.
What this will mean practically is that within code, one can always rely
upon the data directory being in php_dir/data.
If your package is PEAR2_Blah and you're in PEAR2/Blah.php, you can find
the data.txt file via:
$contents = file_get_contents(dirname(__FILE__) .
'../data/PEAR2_Blah/data.txt');
This eliminates the need for any of the weird hacks I had proposed
originally to locate data files for PEAR2.
Comments? Does anyone actually NEED to be able to move data_dir to a
different location for anything other than the need to have a separate
www frontend?
I will update the RFC on the wiki in 3 weeks to reflect this change if
feedback is positive.
Thanks,
Greg