开发者

How to use namespaces and folder structure correctly in Zend Framework models?

I've read about folder structure in Zend Framework and I wanted to put my application logic into correct place folder called models. I've also read that Zend by default uses Zend_Loader_Autoloader_Resource.

I've created subf开发者_运维知识库older My/Service and put there my php files.

Now I have copule of questions:

  • Should classes in those files should be namespaced?

File is put in application/models/My/Service/Page.php

namespace My\Service;

class Page extends Service {
  • How should I access this class in code?

    new Jubiler\Service\Page()

  • How prefixes and namespaces are related?


There are manyways for this..if you follow the exact naming concentions in zend framework..the class will load automatically ..heres the way\ 1.In your config file add appnamespace = "Foo" If you have a File called Test.php in your library folder with a folder Bar (/libray/Bar/Test.php then the class name must be Foo_Bar_Test In this way you can autoload the class

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜