# The Yaf_Application class

(Yaf >=1.0.0)

## Introduction

Yaf_Application provides a bootstrapping facility for applications which provides reusable resources, common- and module-based bootstrap classes and dependency checking.

> Note:

> Yaf_Application implements the singleton pattern, and Yaf_Application can not be serialized or unserialized which will cause problem when you try to use PHPUnit to write some test case for Yaf.

> You may use @backupGlobals annotation of PHPUnit to control the backup and restore operations for global variables. thus can solve this problem.

## Class synopsis

final class Yaf_Application {
/* Properties */
protected $config;
protected $dispatcher;
protected static $_app;
protected $_modules;
protected $_running;
protected $_environ;
/* Methods */
public function __construct(mixed `$config`, string `$environ` = ?)
public static function app(): mixed
public function bootstrap(Yaf_Bootstrap_Abstract `$bootstrap` = ?): void
public function clearLastError(): Yaf_Application
public function environ(): void
public function execute(callable `$entry`, string `...$args`): void
public function getAppDirectory(): Yaf_Application
public function getConfig(): Yaf_Config_Abstract
public function getDispatcher(): Yaf_Dispatcher
public function getLastErrorMsg(): string
public function getLastErrorNo(): int
public function getModules(): array
public function run(): void
public function setAppDirectory(string `$directory`): Yaf_Application
public function __destruct()
}

## Properties

config

dispatcher

_app

_modules

_running

_environ

## Table of Contents

- Yaf_Application::app — Retrieve an Application instance
- Yaf_Application::bootstrap — Call bootstrap
- Yaf_Application::clearLastError — Clear the last error info
- Yaf_Application::__construct — Yaf_Application constructor
- Yaf_Application::__destruct — The __destruct purpose
- Yaf_Application::environ — Retrive environ
- Yaf_Application::execute — Execute a callback
- Yaf_Application::getAppDirectory — Get the application directory
- Yaf_Application::getConfig — Retrive the config instance
- Yaf_Application::getDispatcher — Get Yaf_Dispatcher instance
- Yaf_Application::getLastErrorMsg — Get message of the last occurred error
- Yaf_Application::getLastErrorNo — Get code of last occurred error
- Yaf_Application::getModules — Get defined module names
- Yaf_Application::run — Start Yaf_Application
- Yaf_Application::setAppDirectory — Change the application directory

`↑` and `↓` to navigate • `Enter` to select • `Esc` to close • `/` to open