Is there a way to put your own code into namespaces using cakephp? The following very simple controller class works fine.
class Customer extends \AppModel {
v开发者_运维百科ar $name = 'Customer';
}
However, if I add
namespace foo\bar;
cakephp can't find the controller anymore. Is there some way to tell cake in which namespace it should look for controllers?
I am using cakephp 1.3 and php 5.3.
I don't think there is. CakePHP looks for classes like PostsController
or BlogController
, not foo\bar\PostsController
. Maybe you can tell CakePHP in what folder to look for those classes (probably), but then it will still be looking for unnamepsaced class names.
Why would you want this in a framework that doesn't use namespaces?
Why not give up the App::import()
in cakephp 1.3. Replace it with the include_once()
.
I got my customize vendor classes defined under a namespace works fine. Just to prevent the collision of the custom class name with the official one.
精彩评论