php - in Zend Framework 2 or 3, can module name be same as class name? -
we create module our project called memcached
. way can have namespaced services (e.g. memcached\service\get
) perform actions using php's installed memcached
class.
however, notice following lines in zendframework/zend-modulemanager/src/listener/moduleresolverlistener.php
if (class_exists($modulename)) { return new $modulename; }
this means if name our module memcached
, loading module not work. module instantiated memcached
object rather desired memcached\module
object.
so, there way can name our module memcached
? or, need more creative , name our module memcachedmodule
? prefer not latter since none of our other modules have module
suffix.
module zend thing written using php classes. cant have 2 classes same name, cant import "module class" , "own class" same name, related if working in 1 namespace. can access classes full namespace. here example.
<?php namespace my\space; class theone { function __construct() { print "my 1 created\n"; } } namespace other\space; use my\space\theone myone; class theone { function __construct() { print "other 1 created\n"; } } new theone(); //other 1 created new myone(); //my 1 created
Comments
Post a Comment