Jiew Meng
Jiew Meng

Reputation: 88197

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\Websites\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

Upvotes: 2

Views: 1612

Answers (3)

Jiew Meng
Jiew Meng

Reputation: 88197

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.

Upvotes: 0

Gordon
Gordon

Reputation: 316969

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:

Upvotes: 2

Mchl
Mchl

Reputation: 62377

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 {

Upvotes: 0

Related Questions