1 <?xml version="1.0" encoding="UTF-8"?>
3 <sect2 id="zend.application.available-resources.modules">
4 <title>Zend_Application_Resource_Modules</title>
7 <classname>Zend_Application_Resource_Modules</classname> is used to initialize
8 your application modules. If your module has a
9 <filename>Bootstrap.php</filename> file in its root, and it contains a class
10 named <classname>Module_Bootstrap</classname> (where "Module" is the module name),
11 then it will use that class to bootstrap the module.
15 By default, an instance of
16 <classname>Zend_Application_Module_Autoloader</classname> will be created for the
17 module, using the module name and directory to initialize it.
21 Since the Modules resource does not take any arguments by default, in order to enable it
22 via configuration, you need to create it as an empty array. In <acronym>INI</acronym> style
23 configuration, this looks like:
26 <programlisting language="ini"><![CDATA[
31 In <acronym>XML</acronym> style configuration, this looks like:
34 <programlisting language="xml"><![CDATA[
37 <!-- Placeholder to ensure an array is created -->
44 Using a standard <acronym>PHP</acronym> array, simply create it as an empty array:
47 <programlisting language="php"><![CDATA[
56 <title>Front Controller Resource Dependency</title>
59 The Modules resource has a dependency on the <link
60 linkend="zend.application.available-resources.frontcontroller">Front
61 Controller resource</link>. You can, of course, provide your own
62 replacement for that resource via a custom Front Controller resource
63 class or a class initializer method -- so long as the resource
64 plugin class ends in "Frontcontroller" or the initializer method is
65 named "_initFrontController" (case insensitive).
69 <example id="zend.application.available-resources.modules.configExample">
70 <title>Configuring Modules</title>
73 You can specify module-specific configuration using the module name
74 as a prefix or sub-section in your configuration file.
78 For example, let's assume that your application has a "news" module.
79 The following are <acronym>INI</acronym> and <acronym>XML</acronym> examples showing
80 configuration of resources in that module.
83 <programlisting language="ini"><![CDATA[
85 news.resources.db.adapter = "pdo_mysql"
86 news.resources.db.params.host = "localhost"
87 news.resources.db.params.username = "webuser"
88 news.resources.db.params.password = "XXXXXXX"
89 news.resources.db.params.dbname = "news"
92 <programlisting language="xml"><![CDATA[
99 <adapter>pdo_mysql</adapter>
101 <host>localhost</host>
102 <username>webuser</username>
103 <password>XXXXXXX</password>
104 <dbname>news</dbname>
106 <isDefaultAdapter>true</isDefaultAdapter>
115 <example id="zend.application.available-resources.modules.retrieveBootstrapExample">
116 <title>Retrieving a specific module bootstrap</title>
119 On occasion, you may need to retrieve the bootstrap object for a
120 specific module -- perhaps to run discrete bootstrap methods, or to
121 fetch the autoloader in order to configure it. This can be done
122 using the Modules resource's <methodname>getExecutedBootstraps()</methodname>
126 <programlisting language="php"><![CDATA[
127 $resource = $bootstrap->getPluginResource('modules');
128 $moduleBootstraps = $resource->getExecutedBootstraps();
129 $newsBootstrap = $moduleBootstraps['news'];