Become Zend Certified

Prepare for the ZCE exam using our quizzes (web or iPad/iPhone). More info...

When you're ready get 7.5% off your exam voucher using voucher CJQNOV23 at the Zend Store


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.

Table 2. Zend_Application options

Option Description

Array of php.ini settings to use. Keys should be the php.ini keys.


Additional paths to prepend to the include_path. Should be an array of paths.


Array of additional namespaces to register with the Zend_Loader_Autoloader instance.


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.

Table 3. 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.

      As of 1.10, you may also pass multiple paths containing config files to be merged into a single configuration. This assists in reducing config duplication across many contexts which share common settings (e.g. configs for HTTP, or CLI, each sharing some characteristics but with their own conflicting values for others) or merely splitting a long configuration across many smaller categorised files. The parameter in this case is an array with a single key "config" whose value is an array of the files to merge. Note: this means you either pass a literal path, or array("config"=>array("/path1","/path2"[,...]));.

    • 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.

Zend Framework