2.2. Running Zym_App

2.2. Running Zym_App

Basic usage of Zym_App is as simple as a single function call; however, you can still do manual setup and dispatching. All this component needs to run is the configuration and the environment to run.

Example 2.2. Simple dispatching of Zym_App

The static run() function is in a way similar to Zend_Controller_Front::run() because it allows basic configuration of the component and dispatching.

Zym_App::run('../bootstrap.xml', Zym_App::ENV_DEVELOPMENT);

Example 2.3. Advanced dispatching of Zym_App

Because this component should be very flexible, it has a vast amount of configuration options and ways to modify its behavior. Advanced dispatching will be needed if you intend to modify other attributes not allowed in run().

<?php
$app = Zym_App::getInstance();
$app->setEnvironment(Zym_App::ENV_PRODUCTION);
$app->setConfig('../bootstrap.ini');
 
// Dispatch
$app->dispatch();

[Note] Importance of order

Because config setup will use the environment to determine what to load, it is important that you set the environment before you set the configuration else you may get unexpected results.