Application
final class 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 Application | $_app | ||
protected Config_Abstract | $config | ||
protected 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
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 $envrion = null)
No description
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.
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 Application|null
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".
Application
bootstrap(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.
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".
Dispatcher
getDispatcher()
No description
Application
setAppDirectory(string $directory)
Change the application directory
string
getAppDirectory()
No description
int
getLastErrorNo()
No description
string
getLastErrorMsg()
No description
clearLastError()
No description
__destruct()
No description