本文整理汇总了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();
}