note 92707 deleted from language.namespaces.definition by salathe
[email protected] Tue, 15 Feb 2011 08:24:48 -0800
| Newsgroups | php.notes |
|---|---|
| Message-ID | <[email protected]> |
Note Submitter: jurrien at jpdokter dot nl
----
I have written a Packager class that allows to use packages and namespaces. It does require the folder layout. If the __autoload function is not yet "re-implemented", it'll create its own __autoload function.
It is written in PHP5 and does not require > PHP5.3, moreover, I don't have PHP5.3 since XAMPP is not adding it yet. Don't ask me why.
Since it's over 300 lines long, I am not going to post it here. But if someone would like to have a look?
Basic uses:
<?php
# /classes
# /package1
# class34.class.php
# /package2
# classone.class.php
require_once('packager.class.php');
#Packager::debug(true);
Packager::addClasspath(dirname(__FILE__).'/classes', true); // true means that it overrules the predefined set.
Packager::addClassSuffix(array('.class.php'),true); // true means that it overrules the predefined set.
Packager::import("package1.Class34"); // java-style
Packager::import("package2::ClassOne"); // php-style
echo Packager::dump(); // show us what you got!
?>