本文整理汇总了PHP中FeatherBB\Core\Utils::get_microtime方法的典型用法代码示例。如果您正苦于以下问题:PHP Utils::get_microtime方法的具体用法?PHP Utils::get_microtime怎么用?PHP Utils::get_microtime使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FeatherBB\Core\Utils
的用法示例。
在下文中一共展示了Utils::get_microtime方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: get_info
public static function get_info()
{
$data = array('exec_time' => Utils::get_microtime() - Container::get('start'));
$data['nb_queries'] = isset(DB::get_query_log()[0]) ? count(DB::get_query_log()[0]) : 'N/A';
$data['mem_usage'] = function_exists('memory_get_usage') ? Utils::file_size(memory_get_usage()) : 'N/A';
$data['mem_peak_usage'] = function_exists('memory_get_peak_usage') ? Utils::file_size(memory_get_peak_usage()) : 'N/A';
return $data;
}
示例2: get_info
public static function get_info()
{
self::$feather = \Slim\Slim::getInstance();
$data = array('exec_time' => Utils::get_microtime() - self::$feather->start);
$data['nb_queries'] = isset(DB::get_query_log()[0]) ? count(DB::get_query_log()[0]) : 'N/A';
$data['mem_usage'] = function_exists('memory_get_usage') ? Utils::file_size(memory_get_usage()) : 'N/A';
$data['mem_peak_usage'] = function_exists('memory_get_peak_usage') ? Utils::file_size(memory_get_peak_usage()) : 'N/A';
return $data;
}
示例3: __invoke
public function __invoke($req, $res, $next)
{
// Set headers
$res = $this->set_headers($res);
// Block prefetch requests
if (isset($this->app->environment['HTTP_X_MOZ']) && $this->app->environment['HTTP_X_MOZ'] == 'prefetch') {
return $this->app->response->setStatus(403);
// Send forbidden header
}
// Populate Slim object with forum_env vars
Container::set('forum_env', $this->forum_env);
// Load FeatherBB utils class
Container::set('utils', function ($container) {
return new Utils();
});
// Record start time
Container::set('start', Utils::get_microtime());
// Define now var
Container::set('now', function () {
return time();
});
// Load FeatherBB cache
Container::set('cache', function ($container) {
$path = $this->forum_env['FORUM_CACHE_DIR'];
return new \FeatherBB\Core\Cache(array('name' => 'feather', 'path' => $path, 'extension' => '.cache'));
});
// Load FeatherBB permissions
Container::set('perms', function ($container) {
return new \FeatherBB\Core\Permissions();
});
// Load FeatherBB preferences
Container::set('prefs', function ($container) {
return new \FeatherBB\Core\Preferences();
});
// Load FeatherBB view
Container::set('template', function ($container) {
return new View();
});
// Load FeatherBB url class
Container::set('url', function ($container) {
return new Url();
});
// Load FeatherBB hooks
Container::set('hooks', function ($container) {
return new Hooks();
});
// Load FeatherBB email class
Container::set('email', function ($container) {
return new Email();
});
Container::set('parser', function ($container) {
return new Parser();
});
// Set cookies
Container::set('cookie', function ($container) {
$request = $container->get('request');
return new \Slim\Http\Cookies($request->getCookieParams());
});
Container::set('flash', function ($c) {
return new \Slim\Flash\Messages();
});
// This is the very first hook fired
Container::get('hooks')->fire('core.start');
if (!is_file(ForumEnv::get('FORUM_CONFIG_FILE'))) {
// Reset cache
Container::get('cache')->flush();
$installer = new \FeatherBB\Controller\Install();
return $installer->run();
}
// Load config from disk
include ForumEnv::get('FORUM_CONFIG_FILE');
if (isset($featherbb_config) && is_array($featherbb_config)) {
$this->forum_settings = array_merge(self::load_default_forum_settings(), $featherbb_config);
} else {
$this->app->response->setStatus(500);
// Send forbidden header
return $this->app->response->setBody('Wrong config file format');
}
// Init DB and configure Slim
self::init_db($this->forum_settings, ForumEnv::get('FEATHER_SHOW_INFO'));
Config::set('displayErrorDetails', ForumEnv::get('FEATHER_DEBUG'));
if (!Container::get('cache')->isCached('config')) {
Container::get('cache')->store('config', \FeatherBB\Model\Cache::get_config());
}
// Finalize forum_settings array
$this->forum_settings = array_merge(Container::get('cache')->retrieve('config'), $this->forum_settings);
Container::set('forum_settings', $this->forum_settings);
// Set default style and assets
Container::get('template')->setStyle(ForumSettings::get('o_default_style'));
Container::get('template')->addAsset('js', 'style/themes/FeatherBB/phone.min.js');
// Run activated plugins
self::loadPlugins();
// Define time formats and add them to the container
Container::set('forum_time_formats', array(ForumSettings::get('o_time_format'), 'H:i:s', 'H:i', 'g:i:s a', 'g:i a'));
Container::set('forum_date_formats', array(ForumSettings::get('o_date_format'), 'Y-m-d', 'Y-d-m', 'd-m-Y', 'm-d-Y', 'M j Y', 'jS M Y'));
// Call FeatherBBAuth middleware
return $next($req, $res);
}
示例4: call
public function call()
{
global $forum_time_formats, $forum_date_formats;
// Legacy
// Set headers
$this->set_headers();
// Block prefetch requests
if (isset($this->app->environment['HTTP_X_MOZ']) && $this->app->environment['HTTP_X_MOZ'] == 'prefetch') {
return $this->app->response->setStatus(403);
// Send forbidden header
}
// Populate Slim object with forum_env vars
$this->hydrate('forum_env', $this->forum_env);
// Load FeatherBB utils class
$this->app->container->singleton('utils', function () {
return new Utils();
});
// Record start time
$this->app->start = Utils::get_microtime();
// Define now var
$this->app->now = function () {
return time();
};
// Load FeatherBB cache
$this->app->container->singleton('cache', function ($container) {
$path = $container->forum_env['FORUM_CACHE_DIR'];
return new \FeatherBB\Core\Cache(array('name' => 'feather', 'path' => $path, 'extension' => '.cache'));
});
// Load FeatherBB view
$this->app->container->singleton('template', function () {
return new \FeatherBB\Core\View();
});
// Load FeatherBB url class
$this->app->container->singleton('url', function () {
return new \FeatherBB\Core\Url();
});
// Load FeatherBB hooks
$this->app->container->singleton('hooks', function () {
return new \FeatherBB\Core\Hooks();
});
// Load FeatherBB email class
$this->app->container->singleton('email', function () {
return new \FeatherBB\Core\Email();
});
$this->app->container->singleton('parser', function () {
return new \FeatherBB\Core\Parser();
});
// This is the very first hook fired
$this->app->hooks->fire('core.start');
if (!is_file($this->forum_env['FORUM_CONFIG_FILE'])) {
$installer = new \FeatherBB\Controller\Install();
$installer->run();
return;
}
// Load config from disk
include $this->forum_env['FORUM_CONFIG_FILE'];
if (isset($featherbb_config) && is_array($featherbb_config)) {
$this->forum_settings = array_merge(self::load_default_forum_settings(), $featherbb_config);
} else {
$this->app->response->setStatus(500);
// Send forbidden header
return $this->app->response->setBody('Wrong config file format');
}
// Init DB and configure Slim
self::init_db($this->forum_settings, $this->forum_env['FEATHER_SHOW_INFO']);
$this->app->config(array('debug' => $this->forum_env['FEATHER_DEBUG'], 'cookies.encrypt' => true, 'cookies.secret_key' => $this->forum_settings['cookie_seed']));
if (!$this->app->cache->isCached('config')) {
$this->app->cache->store('config', \FeatherBB\Model\Cache::get_config());
}
// Finalize forum_settings array
$this->forum_settings = array_merge($this->app->cache->retrieve('config'), $this->forum_settings);
// Set default style and assets
$this->app->template->setStyle($this->forum_settings['o_default_style']);
$this->app->template->addAsset('js', 'style/themes/FeatherBB/phone.min.js');
// Populate FeatherBB Slim object with forum_settings vars
$this->hydrate('forum_settings', $this->forum_settings);
$this->app->config = $this->forum_settings;
// Legacy
extract($this->forum_settings);
// Legacy
// Run activated plugins
self::loadPlugins();
// Define time formats
$forum_time_formats = array($this->forum_settings['o_time_format'], 'H:i:s', 'H:i', 'g:i:s a', 'g:i a');
$forum_date_formats = array($this->forum_settings['o_date_format'], 'Y-m-d', 'Y-d-m', 'd-m-Y', 'm-d-Y', 'M j Y', 'jS M Y');
// Call FeatherBBAuth middleware
$this->next->call();
}