python - How can php-files find namespaces in other php-files? -
coming python i'm trying make sense of way php uses namespaces. in python import follows:
import somemodule anothermodule import someclass
this works charm , expect.
in php on other hand, we've got namespaces. far understand can define namespace on top of mymodule.php this:
namespace mynamespace;
if i'm correct means code in file can referred (or imported by) name "mynamespace" in myworkingcode.php doing this:
use mynamespace;
so question; how myworkingcode.php find mymodule.php? need in same folder work or need else?
the use function in php completly different import in python.
use there creating aliases long namespaces. example:
use \my\very\long\omg\its\sooooo\long\how\stupid veryshort;
now every class inside long namespace available under namespace veryshort. more info: http://php.net/manual/en/language.namespaces.importing.php
then, how php find correct file? doesn't. have include yourself, if use strong naming convention files can use autoloaders spl_autoload_register function. standard can found here: http://www.php-fig.org/psr/0/
Comments
Post a Comment