Yaf_Application
final class Yaf_Application (View source)
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 un-serialized 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.
Properties
static protected Yaf_Application | $_app | ||
protected Yaf_Config_Abstract | $config | ||
protected Yaf_Dispatcher | $dispatcher | ||
protected array | $_modules | ||
protected string | $_running | ||
protected string | $_environ | ||
protected int
Since: 2.1.2
|
$_err_no | ||
protected string
Since: 2.1.2
|
$_err_msg |
Methods
No description
No description
Run a Yaf_Application, let the Yaf_Application accept a request, and route the request, dispatch to controller/action, and render response.
This method is typically used to run Yaf_Application in a crontab work.
Retrieve the Yaf_Application instance, alternatively, we also could use Yaf_Dispatcher::getApplication().
Retrieve environ which was defined in yaf.environ which has a default value "product".
Run a Bootstrap, all the methods defined in the Bootstrap and named with prefix "_init" will be called according to their declaration order, if the parameter bootstrap is not supplied, Yaf will look for a Bootstrap under application.directory.
No description
Get the modules list defined in config, if no one defined, there will always be a module named "Index".
No description
Change the application directory
No description
No description
No description
No description
No description
Details
__construct(string|array $config, string $environ = null)
No description
Yaf_Application
getInstance()
No description
void
run()
Run a Yaf_Application, let the Yaf_Application accept a request, and route the request, dispatch to controller/action, and render response.
return response to client finally.
void
execute(callable $entry, string ...$_)
This method is typically used to run Yaf_Application in a crontab work.
Make the crontab work can also use the autoloader and Bootstrap mechanism.
static Yaf_Application
app()
Retrieve the Yaf_Application instance, alternatively, we also could use Yaf_Dispatcher::getApplication().
string
environ()
Retrieve environ which was defined in yaf.environ which has a default value "product".
Yaf_Application
bootstrap(Yaf_Bootstrap_Abstract $bootstrap = null)
Run a Bootstrap, all the methods defined in the Bootstrap and named with prefix "_init" will be called according to their declaration order, if the parameter bootstrap is not supplied, Yaf will look for a Bootstrap under application.directory.
Yaf_Config_Abstract
getConfig()
No description
array
getModules()
Get the modules list defined in config, if no one defined, there will always be a module named "Index".
Yaf_Dispatcher
getDispatcher()
No description
Yaf_Application
setAppDirectory(string $directory)
Change the application directory
string
getAppDirectory()
No description
int
getLastErrorNo()
No description
string
getLastErrorMsg()
No description
void
clearLastError()
No description
__destruct()
No description