开发者

CakePHP and namespaces?

开发者 https://www.devze.com 2023-03-06 02:20 出处:网络
Is there a way to put your own code into namespaces using cakephp? The following very simple controller class works fine.

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消