# Zend_Application

`Zend_Application` provides the base functionality of the component, and the entry point to your Zend Framework application. It's purpose is two-fold: to setup the PHP environment (including autoloading), and to execute your application bootstrap.

Typically, you will pass all configuration to the `Zend_Application` constructor, but you can also configure the object entirely using its own methods. This reference is intended to illustrate both use cases.

## Zend_Application options

Option | Description
--- | ---
phpSettings | Array of `php.ini` settings to use. Keys should be the `php.ini` keys.
includePaths | Additional paths to prepend to the include_path. Should be an array of paths.
autoloaderNamespaces | Array of additional namespaces to register with the `Zend_Loader_Autoloader` instance.
bootstrap | Either the string path to the bootstrap class, or an array with elements for the 'path' and 'class' for the application bootstrap.

## Option names

Please note that option names are case insensitive.

## Zend_Application Methods

Method | Return Value | Parameters | Description
--- | --- | --- | ---

`__construct($environment, $options = null)`

Void

- `$environment`: required,. String representing the current application environment. Typical strings might include "development", "testing", "qa", or "production", but will be defined by your organizational requirements.

- `$options`: optional. Argument may be one of the following values:

  - String: path to a `Zend_Config` file to load as configuration for your application. `$environment` will be used to determine what section of the configuration to pull.

  - Array: associative array of configuration data for your application.

  - `Zend_Config`: configuration object instance.

Constructor. Arguments are as described, and will be used to set initial object state. An instance of `Zend_Loader_Autoloader` is registered during instantiation. Options passed to the constructor are passed to `setOptions()`.

`getEnvironment()` | String | N/A | Retrieve the environment string passed to the constructor.
`getAutoloader()` | `Zend_Loader_Autoloader` | N/A | Retrieve the `Zend_Loader_Autoloader` instance registered during instantiation.

`setOptions(array $options)`

`Zend_Application`

- `$options`: required. An array of application options.

All options are stored internally, and calling the method multiple times will merge options. Options matching the various setter methods will be passed to those methods. As an example, the option "phpSettings" will then be passed to `setPhpSettings()`. (Option names are case insensitive.)

`getOptions()` | Array | N/A | Retrieve all options used to initialize the object; could be used to cache `Zend_Config` options to a serialized format between requests.

`hasOption($key)`

Boolean

- `$key`: String option key to lookup

Determine whether or not an option with the specified key has been registered. Keys are case insensitive.

`getOption($key)`

Mixed

- `$key`: String option key to lookup

Retrieve the option value of a given key. Returns `NULL` if the key does not exist.

`setPhpSettings(array $settings, $prefix = '')`

`Zend_Application`

- `$settings`: required. Associative array of PHP INI settings.

- `$prefix`: optional. String prefix with which to prepend option keys. Used internally to allow mapping nested arrays to dot-separated `php.ini` keys. In normal usage, this argument should never be passed by a user.

Set run-time `php.ini` settings. Dot-separated settings may be nested hierarchically (which may occur with INI `Zend_Config` files) via an array-of-arrays, and will still resolve correctly.

`setAutoloaderNamespaces(array $namespaces)`

`Zend_Application`

- `$namespaces`: required. Array of strings representing the namespaces to register with the `Zend_Loader_Autoloader` instance.

Register namespaces with the `Zend_Loader_Autoloader` instance.

`setBootstrap($path, $class = null)`

`Zend_Application`

- `$path`: required. May be either a `Zend_Application_Bootstrap_Bootstrapper` instance, a string path to the bootstrap class, an associative array of classname => filename, or an associative array with the keys 'class' and 'path'.

- `$class`: optional. If `$path` is a string, `$class` may be specified, and should be a string class name of the class contained in the file represented by path.

`getBootstrap()` | `NULL` | `Zend_Application_Bootstrap_Bootstrapper` | N/A | Retrieve the registered bootstrap instance.
`bootstrap()` | Void | N/A | Call the bootstrap's `bootstrap()` method to bootstrap the application.
`run()` | Void | N/A | Call the bootstrap's `run()` method to dispatch the application.