I know this is quite silly to ask, I oftentimes see this term on the documentation but I still don't get enlightened by such contexts I encounter. What is the difference between "resources" and "libraries". In my assumption I made the conclusion that they are just set of loaded classes. I would like to make sure if I am correct. But I do not comprehend why they included the functionality of the Zend_Cache, Zend_Translate, Zend_Dojo etc. on the Zend_Application_Resource. Thank you very much and please excuse my English.
问题:
回答1:
Resources are objects you initialise during bootstrap via your configuration file and are generally available to your entire application.
There are a set of built-in resources as described here - http://framework.zend.com/manual/en/zend.application.available-resources.html
You can also provide your own.
A library is a collection of classes that you may use in your application. Objects are generally instantiated when required.
回答2:
Simply, a resource is a logical entity which can be used to load & run a zend framework application and used as supply/reserve/store for the application. some resource are loaded automatically by zend framework itself and some you have to or for some resources you just provide configurations.
In Zend Framework, resource term used in the context of zf application to denote the followings like:
- cachemanager
- db
- multidb
- frontController
- layout
- locale
- log
- mail
- modules
- navigation
- router
- session
- translate adapter resource
- useragent
- view etc.
Syntax: Zend_Application_Resource_ResourceName
Sample resource loading description:
Zend_Application_Resource_Modules
Zend_Application_Resource_Modules is used to initialize your application modules. If your module has a Bootstrap.php file in its root, and it contains a class named _Module_Bootstrap_ (where "Module" is the module name), then it will use that class to bootstrap the module.
By default, an instance of _Zend_Application_Module_Autoloader_ will be created for the module, using the module name and directory to initialize it.
Since the Modules resource does not take any arguments by default, in order to enable it via configuration, you need to create it as an empty array. In INI(application.ini) style configuration, this looks like:
resources.modules[] =
In XML style configuration, this looks like:
<resources>
<modules>
<!-- Placeholder to ensure an array is created -->
<placeholder />
</modules>
</resources>
Using a standard PHP array, simply create it as an empty array:
$options = array(
'resources' => array(
'modules' => array(),
),
);
can check out More Here