phpday 2027 - Call for Papers

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 problems when you try to use PHPUnit to write some test cases for Yaf.

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

Class synopsis

final class Yaf_Application {
/* Properties */
protected $config;
protected $dispatcher;
protected static $_app;
protected $_modules;
protected $_running;
protected $_environ;
protected $_err_no;
protected $_err_msg;
/* Methods */
public function __construct(string|array $config, ?string $environ = null)
public static function app(): ?Yaf_Application
public function bootstrap(): Yaf_Application|false
public function clearLastError(): ?Yaf_Application
public function environ(): ?string
public function execute(callable $callback, mixed ...$args): mixed
public function getAppDirectory(): ?string
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(): Yaf_Response_Abstract|false
public function setAppDirectory(string $directory): Yaf_Application|null|false
}

Properties

config

The application configuration object.

dispatcher

The Yaf_Dispatcher instance used by this application.

_app

Static reference to the single running application instance.

_modules

The list of registered module names, parsed from application.modules.

_running

Whether the application is currently running.

_environ

The environment name of the application, defaults to "product".

_err_no

The code of the last error, one of the YAF_ERR_* constants.

_err_msg

The message of the last error.

Table of Contents

User Contributed Notes

There are no user contributed notes for this page.
Adding new notes is disabled. Please see the links in the Found A Problem? section.
To Top