1 <?xml version="1.0" encoding="UTF-8"?>
3 <sect2 id="zend.application.core-functionality.application">
4 <title>Zend_Application</title>
7 <classname>Zend_Application</classname> provides the base functionality of the
8 component, and the entry point to your Zend Framework application. It's
9 purpose is two-fold: to setup the <acronym>PHP</acronym> environment (including
10 autoloading), and to execute your application bootstrap.
14 Typically, you will pass all configuration to the
15 <classname>Zend_Application</classname> constructor, but you can also configure
16 the object entirely using its own methods. This reference is intended to
17 illustrate both use cases.
20 <table id="zend.application.core-functionality.application.api.options">
21 <title>Zend_Application options</title>
27 <entry>Description</entry>
33 <entry><emphasis><property>phpSettings</property></emphasis></entry>
37 Array of <filename>php.ini</filename> settings to use. Keys should be
38 the <filename>php.ini</filename> keys.
44 <entry><emphasis><property>includePaths</property></emphasis></entry>
48 Additional paths to prepend to the <emphasis>include_path</emphasis>.
49 Should be an array of paths.
55 <entry><emphasis><property>autoloaderNamespaces</property></emphasis></entry>
59 Array of additional namespaces to register with the
60 <classname>Zend_Loader_Autoloader</classname> instance.
66 <entry><emphasis><property>bootstrap</property></emphasis></entry>
70 Either the string path to the bootstrap class, or an array
71 with elements for the 'path' and 'class' for the application
81 <title>Option names</title>
84 Please note that option names are case insensitive.
88 <table id="zend.application.core-functionality.application.api.table">
89 <title>Zend_Application Methods</title>
95 <entry>Return Value</entry>
96 <entry>Parameters</entry>
97 <entry>Description</entry>
104 <methodname>__construct($environment, $options = null)</methodname>
107 <entry><type>Void</type></entry>
113 <varname>$environment</varname>: <emphasis>required</emphasis>,.
114 String representing the current application
115 environment. Typical strings might include
116 "development", "testing", "qa", or
117 "production", but will be defined by your
118 organizational requirements.
124 <varname>$options</varname>: <emphasis>optional</emphasis>.
125 Argument may be one of the following values:
131 <emphasis><type>String</type></emphasis>: path to
132 a <classname>Zend_Config</classname> file to load
133 as configuration for your application.
134 <varname>$environment</varname> will be used
135 to determine what section of the
136 configuration to pull.
140 As of 1.10, you may also pass multiple paths containing
141 config files to be merged into a single configuration.
142 This assists in reducing config duplication across many
143 contexts which share common settings (e.g. configs for
144 <acronym>HTTP</acronym>, or <acronym>CLI</acronym>, each
145 sharing some characteristics but with their own
146 conflicting values for others) or merely splitting a
147 long configuration across many smaller categorised
148 files. The parameter in this case is an array with a
149 single key "configs" whose value is an array of the
150 files to merge. Note: this means you either pass a
152 <command>array("configs"=>array("/path1","/path2"[,...]));</command>.
158 <emphasis><type>Array</type></emphasis>: associative
159 array of configuration data for your application.
165 <emphasis><classname>Zend_Config</classname></emphasis>:
166 configuration object instance.
176 Constructor. Arguments are as described, and will be
177 used to set initial object state. An instance of
178 <classname>Zend_Loader_Autoloader</classname> is registered
179 during instantiation. Options passed to the
180 constructor are passed to <methodname>setOptions()</methodname>.
186 <entry><methodname>getEnvironment()</methodname></entry>
187 <entry><type>String</type></entry>
191 <para>Retrieve the environment string passed to the constructor.</para>
196 <entry><methodname>getAutoloader()</methodname></entry>
197 <entry><classname>Zend_Loader_Autoloader</classname></entry>
202 Retrieve the <classname>Zend_Loader_Autoloader</classname>
203 instance registered during instantiation.
209 <entry><methodname>setOptions(array $options)</methodname></entry>
210 <entry><classname>Zend_Application</classname></entry>
216 <varname>$options</varname>: <emphasis>required</emphasis>.
217 An array of application options.
225 All options are stored internally, and calling the
226 method multiple times will merge options. Options
227 matching the various setter methods will be passed
228 to those methods. As an example, the option
229 "phpSettings" will then be passed to
230 <methodname>setPhpSettings()</methodname>. (Option names are
237 <entry><methodname>getOptions()</methodname></entry>
238 <entry><type>Array</type></entry>
243 Retrieve all options used to initialize the object;
244 could be used to cache <classname>Zend_Config</classname>
245 options to a serialized format between requests.
251 <entry><methodname>hasOption($key)</methodname></entry>
252 <entry><type>Boolean</type></entry>
257 <varname>$key</varname>: String option key to lookup
265 Determine whether or not an option with the
266 specified key has been registered. Keys are case insensitive.
272 <entry><methodname>getOption($key)</methodname></entry>
273 <entry><type>Mixed</type></entry>
277 <para><varname>$key</varname>: String option key to lookup</para>
284 Retrieve the option value of a given key. Returns
285 <constant>NULL</constant> if the key does not exist.
292 <methodname>setPhpSettings(array $settings, $prefix = '')</methodname>
295 <entry><classname>Zend_Application</classname></entry>
301 <varname>$settings</varname>: <emphasis>required</emphasis>.
302 Associative array of <acronym>PHP</acronym>
303 <acronym>INI</acronym> settings.
309 <varname>$prefix</varname>: <emphasis>optional</emphasis>.
310 String prefix with which to prepend option keys. Used
311 internally to allow mapping nested arrays to dot-separated
312 <filename>php.ini</filename> keys. In normal usage, this
313 argument should never be passed by a user.
321 Set run-time <filename>php.ini</filename> settings. Dot-separated
322 settings may be nested hierarchically (which may occur
323 with <acronym>INI</acronym> <classname>Zend_Config</classname> files)
324 via an array-of-arrays, and will still resolve correctly.
331 <methodname>setAutoloaderNamespaces(array $namespaces)</methodname>
334 <entry><classname>Zend_Application</classname></entry>
340 <varname>$namespaces</varname>: <emphasis>required</emphasis>.
341 Array of strings representing the namespaces to
342 register with the <classname>Zend_Loader_Autoloader</classname>
351 Register namespaces with the
352 <classname>Zend_Loader_Autoloader</classname> instance.
358 <entry><methodname>setBootstrap($path, $class = null)</methodname></entry>
359 <entry><classname>Zend_Application</classname></entry>
365 <varname>$path</varname>: <emphasis>required</emphasis>. May be
367 <classname>Zend_Application_Bootstrap_Bootstrapper</classname>
368 instance, a string path to the bootstrap class, an
369 associative array of classname => filename, or an associative
370 array with the keys 'class' and 'path'.
376 <varname>$class</varname>: <emphasis>optional</emphasis>.
377 If <varname>$path</varname> is a string,
378 <varname>$class</varname> may be specified, and should
379 be a string class name of the class contained in
380 the file represented by path.
388 <entry><methodname>getBootstrap()</methodname></entry>
391 <constant>NULL</constant> |
392 <classname>Zend_Application_Bootstrap_Bootstrapper</classname>
396 <entry><para>Retrieve the registered bootstrap instance.</para></entry>
400 <entry><methodname>bootstrap()</methodname></entry>
401 <entry><type>Void</type></entry>
405 Call the bootstrap's <methodname>bootstrap()</methodname>
406 method to bootstrap the application.
412 <entry><methodname>run()</methodname></entry>
413 <entry><type>Void</type></entry>
417 Call the bootstrap's <methodname>run()</methodname>
418 method to dispatch the application.