Hi,
thanks for your reply, but I'm not talking about class loading (because
thats already possible). I'm talking about autoloading of userspace
functions and constants
// /path/to/my/functions.php
namespace my\functions;
const THING = 'I am constant!';
function helloWorld () {
echo "hello World;
}
// /path/to/some/other/file.php
namespace foo;
use my\functions;
functions\helloWorld(); // fail!
echo functions\THING;
Am 26.07.2011 10:27, schrieb Laruence:
Hi:
maybe Yaf_Loader can be used for meet this requirement.
it's a internal autoload function:
Each namespace separator is converted to a DIRECTORY_SEPARATOR when
loading from the file system.
Each "_" character in the CLASS NAME is converted to a
DIRECTORY_SEPARATOR. The "_" character has no special meaning in the
namespace.
The fully-qualified namespace and class is suffixed with ".php" when
loading from the file system.
As examples:
\Doctrine\Common\IsolatedClassLoader =>
/path/to/project/lib/vendor/Doctrine/Common/IsolatedClassLoader.php
\namespace\package\Class_Name =>
/path/to/project/lib/vendor/namespace/package/Class/Name.php
\namespace\package_name\Class_Name =>
/path/to/project/lib/vendor/namespace/package_name/Class/Name.php
http://pecl.php.net/package/Yaf
thanks
2011/7/26 Sebastian Krebs<sebastian.krebs.ber...@googlemail.com>:
Hi,
Maybe this topic occured already, then sorry when I'm wasting your time, but
I'm wondering, why there is no autoloading for functions and
(namespace)constants.
When a class is not found, then an userland function is called. Thus I don't
see a reason, why something like this doesn't exists for functions and
(namespace)constants too, because using them is quite uncomfortable right
now compared to classes and the decision _how_ to load them would be on the
developers-side anyway.
Sebastian Krebs
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php