简体   繁体   中英

In Zend Framework, what is the difference in between creating a bootstrap Init Method and just creating a resource class to do the same thing?

I'm not clear on the difference between creating another _init method within the bootstrap to initialize a resource as opposed to creating a resource class and adding it to the configuration file to be loaded by the bootstrap? Thanks in advance for taking time out of your day to check out my question. Cheers!

Well that's just about flexibility, using a Resource will provide you a more generic object which will fit most of your need for common services while _init methods are likely to be specific and short.

Resources allows you to automatically load config object from the configuration file, while _init methods will ask you to do it manually.

There is no real difference except the way you work with.

  • _init:
    • simple case
    • really specific
    • maybe quicker

  • resources:
    • reusable
    • allow different configuration format (ini, php, xml)
    • maybe slower

Note : _init method with the same names as native resoures will overwrite current configuration.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM