How to use zend autoloader ??

zend autoloader tutorial >>

File Structure:
library

       |--- Amazon


                 |--- Action.php [ with class Amazon_Action ]

In Bootstrap.php
public function _initAutoloaders()
{
    $loader = Zend_Loader_Autoloader::getInstance();
    $loader->registerNamespace('Amazon_');
}

In IndexController or any..
$Amazon_Action = new Amazon_Action();


Now use custom file structure:
In application

   classes
       |--- googles
             |--- nels
                    |--- action.php [with calss name My_Classe_Google_Nel_Action]

             |--- test.php [with class My_Classe_Google_Test] 

       |---demo.php [with class My_Classe_Demo]

In Bootstrap.php
public function _initAutoloaders()
{
 $resourceLoader = new Zend_Loader_Autoloader_Resource(array(
      'basePath' =>  APPLICATION_PATH . '/',
         'namespace' => 'My',
     ));
 
 $resourceLoader->addResourceType('demo','classes/','Classe');

 $resourceLoader->addResourceType('test', 'classes/googles/', 'Classe_Google');

 $resourceLoader->addResourceType('action', 'classes/googles/nels/', 'Classe_Google_Nel');
 
 }

In Controller
$opt1 =  new My_Classe_Google_Nel_Action();
$opt2 = new My_Classe_Google_Test();
$opt3 = new  My_Classe_Demo();
For more advance use of autoloader follow thins link..
http://nelsondesai.blogspot.in/2012/09/advanced-use-of-autoloader-in-zend.html
http://framework.zend.com/manual/1.12/en/learning.autoloading.resources.html

For more details mail me on nelson.desai@gmail.com or comments here.


--
Thank You
Nelson Desai

1 comments:

Anonymous said...

Merkur Solingen No Deposit Bonus Codes 2021
Merkur Solingen 메리트카지노 No Deposit Bonus Codes 2021 - Best Merkur Online Casinos 2021. Discover the Top Casino 인카지노 Listings for Free and win 카지노사이트 real money.

Post a Comment

Twitter Delicious Facebook Digg Stumbleupon Favorites More

 
Design by NDR Group | Bloggerized by Er. Nelson Desai | Love U My Friends