Yaf_Application::app
Retrieve an Application instance
Description
public static Yaf_Applicationnull Yaf_Application::app()
Retrieve the Yaf_Application instance.
Alternatively, Yaf_Dispatcher::getApplication
can also be used.
Parameters
This function has no parameters.
Return Values
The Yaf_Application instance, or null if no
application has been initialized yet.
Examples
Example #1 Yaf_Application::app example
<?php
/* index.php, the application entry */
$config = new Yaf_Config_Ini(__DIR__ . "/conf/application.ini", "product");
$application = new Yaf_Application($config);
$application->bootstrap()->run();
?>
Example #2 Retrieving the application instance elsewhere
<?php
class IndexController extends Yaf_Controller_Abstract
{
public function indexAction()
{
/* Yaf_Application::app() is an alias of getInstance() */
$app = Yaf_Application::app();
var_dump($app->environ());
var_dump(Yaf_Application::getInstance() === $app);
return false;
}
}
?>
The above example will output
something similar to:
string(7) "product"
bool(true)
See Also
- Yaf_Dispatcher::getApplication