CakePHP和命名空间? [英] CakePHP and namespaces?

查看:106
本文介绍了CakePHP和命名空间?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法使用cakephp将你自己的代码放在命名空间?以下非常简单的控制器类工作正常。

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 {
    var $name = 'Customer';
}

但是,如果我添加

namespace foo\bar;

cakephp找不到控制器了。有没有什么方法告诉蛋糕在哪个命名空间它应该寻找控制器?

cakephp can't find the controller anymore. Is there some way to tell cake in which namespace it should look for controllers?

我使用cakephp 1.3和php 5.3。

I am using cakephp 1.3 and php 5.3.

推荐答案

我不认为有。 CakePHP寻找类 PostsController BlogController ,而不是 foo\bar\PostsController 。也许你可以告诉CakePHP在什么文件夹中寻找这些类(可能),但是它仍然会寻找无类别的类名。

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?

这篇关于CakePHP和命名空间?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆