Re[2]: [PEAR-DEV] New package proposal
| From: | Dmitry Koteroff | Date: | Tue, 01 Jun 2004 00:03:54 +0000 |
| Subject: | Re[2]: [PEAR-DEV] New package proposal | ||
| References: | 1 2 3 4 | Groups: | php.pear.dev |
| Request: | Send a blank email to pear-dev+get-29824@lists.php.net to get a copy of this message | ||
>> DC> Perhaps merge it into the PHP_Beautifier project which just passed.
>> DC>
>> DC> http://pear.php.net/pepr/pepr-proposal-show.php?id=74
>>
>> Purpose of my package is NOT beautifying PHP code. It is used on
>> run-time, not while developing.
>>
PJ> I'm not sure promoting such packages for fixes at run time is
PJ> a good idea.
What "fixes" are you talking about at all? Forget about fixes!
1. I am using the following code in my CMS templates:
{t_controller src="Test_Date" name="date" format="Y-m-d"}
{$date}
{/t_controller}
It does:
a) searches for Test_Date class and loads it;
b) calls Test_Date::main() to generate data;
c) uses this data to insert to the page.
PEAR_NameScheme helps to find filename for class Test_Date in
include_path, no more.
2. Next example - PHP5's autoload routine.
class PEAR_NameScheme_Autoload {
# static void classAutoloader(string $classname)
static function classAutoloader($classname) {
$fname = PEAR_NameScheme::name2path($classname);
if ($f = @fopen($fname, "r", true)) {
fclose($f);
return include_once($fname);
}
return false;
}
}
$classname is ALWAYS passed in lowercase, so we need to manually
search for class file in include_path. PEAR_NameScheme helps
again.
--
Best regards,
Dmitry Koteroff.