开发者

Using PHP 5.3 namespaces (Doctrine2) with Zend Framework classes

i am having a situation where my doctrine model, Post, is in the namespace Application\Entities and i want to try to implement Zend_Acl_Resource_Interface. i get the error

Fatal error: Interface 'Application\Entities\Zend_Acl_Resource_Interface' not found in D:\Projects\Website开发者_如何学JAVAs\php\ZendFram ework\LearningZF\library\Application\Entities\Post.php on line 8

namespace Application\Entities;
use DoctrineExtensions\NestedSet\Node;

/**
 * @Entity @Table(name="posts")
 */
class Post implements Node, Zend_Acl_Resource_Interface {

update

if i try

class Post implements Node, \Zend_Acl_Resource_Interface {

Fatal error: Interface 'Zend_Acl_Resource_Interface' not found in D:\Projects\Websites\php\ZendFramework\LearningZF\library\Application\Entities\Post.php on line 8


Are you using the ZF 2.0 branch or the stable one, e.g. 1.10? Is your autoloader setup to load classes with the ZF naming scheme?

You can use the Conversion tool the ZF devs used to convert ZF to using namespaces:

  • http://github.com/ralphschindler/PHPTools
  • http://blog.calevans.com/2010/03/27/zends-new-namespace-converter/


As far as I remember Zend Framework does not uses namespaces (until 2.x comes out anyway) so it's classes are in global namespace. Try class Post implements Node, \Zend_Acl_Resource_Interface {


i am going to put this as an answer, so i can mark this qn as answered if noone have any other answers, its actually a workaround i used. i am not too sure why it worked exactly, or rather why the Zend autoloader failed

i added the require_once to include Zend_Acl_Resource_Interface

namespace Application\Entities;
use DoctrineExtensions\NestedSet\Node;
require_once "Zend/Acl/Resource/Interface.php";

/**
 * @Entity @Table(name="posts")
 */
class Post implements Node, \Zend_Acl_Resource_Interface {

i think a better fix will be to conversion tool in @Gordon's answer. but i cant fix all the errors i get with "unclean" conversion yet. paths are broken.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜