分享

Zend Framework register autoloader namespace | Cuckooo Blog

 sumi2005 2014-12-17

There may be several ways to declace autoloader namespaces but here i am showing you the two ways to set it.

1. The first question arises is the mind is that what are autoloader namespaces and what are its benefits??
Autoloader namespaces are the folder names which works as the custom library collection just like zend framework which use default Zend library folder and all the php file and code are written in the Zend folder and we can use it in our whole application like Zend_ prefix. Similarly we can define our own autoloader namespaces which will be availabe throughout the application.

2. Suppose we have to create Cuck namespace then create Cuck folder under library directory.

3. In application.ini under config folder add this line.

1
autoloaderNamespaces[] = "Cuck_"

4. Or in Bootstrap.php define in _init function.

1
2
3
4
5
6
7
8
9
<?php
Bootstrap.php extends Zend_Application_Bootstrap_Bootstrap{
  protected function _initAutoloaders()
  {    
     $loader = Zend_Loader_Autoloader::getInstance();
     $loader->registerNamespace(array('Cuck_', 'Duck_'))
            ->setFallbackAutoloader(true);
  }
}

any method can be used from point 3 and 4.
hope this could help :)

    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章