本文整理匯總了PHP中Services::getInstance方法的典型用法代碼示例。如果您正苦於以下問題:PHP Services::getInstance方法的具體用法?PHP Services::getInstance怎麽用?PHP Services::getInstance使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Services
的用法示例。
在下文中一共展示了Services::getInstance方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: run
/**
* Run an application
*/
public static function run()
{
// Error reporting
error_reporting(ENV === 'production' ? E_ERROR | E_WARNING | E_PARSE : -1);
ini_set('display_errors', ENV === 'production' ? 0 : 1);
// Services
$services = Services::getInstance();
// Global configuration
$config = $services->config()->get('config');
// UTF-8 support
if (isset($config['utf8']) && $config['utf8']) {
mb_internal_encoding('UTF-8');
mb_http_output('UTF-8');
mb_http_input('UTF-8');
mb_language('uni');
mb_regex_encoding('UTF-8');
ob_start('mb_output_handler');
} else {
ob_start();
}
// Set Locales
if (isset($config['locale']) && $config['locale']) {
setlocale(LC_ALL, $config['locale']);
setlocale(LC_NUMERIC, 'C');
}
// Call controller
if ($route = $services->route()) {
list($class, $method, $params) = $route;
$controller = new $class();
$controller->{$method}(...$params);
}
$services->output()->display(!$services->input()->isClient());
ob_end_flush();
}
示例2: __construct
public function __construct()
{
$this->services = Services::getInstance();
$this->input = $this->services->input();
$this->output = $this->services->output();
}