本文整理汇总了PHP中FirePHP::to方法的典型用法代码示例。如果您正苦于以下问题:PHP FirePHP::to方法的具体用法?PHP FirePHP::to怎么用?PHP FirePHP::to使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FirePHP
的用法示例。
在下文中一共展示了FirePHP::to方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
function __construct()
{
$this->console = FirePHP::to("page")->console();
$this->console = $this->console->options(array('encoder.trace.offsetAdjustment' => 1));
$this->engine = FirePHP::plugin('engine');
$this->engine->onException($this->console);
}
示例2: testConnect
public function testConnect()
{
$console = FirePHP::to('process')->console();
$console->label('Label 1')->log('Hello World 1');
$console->expand()->label('Label 2')->log('Hello World 2');
$console->show();
}
示例3: respond
public function respond($server, $request)
{
if ($request->getAction() == 'TestClient') {
FirePHP::to('controller')->triggerClientTest($request->getArguments());
return array('type' => 'text/plain', 'data' => "OK");
}
return false;
}
示例4: activateOptions
public function activateOptions()
{
if (method_exists('FirePHP', 'to')) {
$this->console = FirePHP::to($this->target)->console();
$this->closed = false;
} else {
$this->warn('FirePHP is not installed correctly. Closing appender.');
}
}
示例5: onMessage
public function onMessage($message)
{
$data = $message->getData();
if (is_array($data) && isset($data['action'])) {
switch ($data['action']) {
case 'showPlugin':
FirePHP::to("plugin")->plugin('PageControls2')->show();
break;
case 'removeAll':
FirePHP::to("plugin")->removeAll();
break;
}
} else {
// relay message back to client
$this->sendSimpleMessage($data);
}
}
示例6: getItems
public function getItems()
{
$this->didLoad = false;
$file = $this->getCachePath();
/*i*/
$this->console->label('Cache File')->log($file);
/*i*/
$this->console->label('Cache File Exists')->log(file_exists($file));
if (file_exists($file)) {
$fileTime = filemtime($file);
$fileTtl = time() - $fileTime;
/*i*/
$this->console->label('Cache Time Remaining')->log($this->ttl - $fileTtl);
} else {
$fileTime = false;
$fileTtl = 0;
}
if ($fileTtl >= $this->ttl || FirePHP::to('request')->console('Feed')->on('Force Reload Cache')->is(true)) {
/*i*/
$this->console->info('Deleting Cache File');
if (file_exists($file)) {
unlink($file);
}
}
if (!file_exists($file)) {
/*i*/
$group = $this->console->group()->open();
/*i*/
$this->console->log('Load feed and store in cache file');
$this->load();
/*i*/
$group->close();
/*i*/
} else {
/*i*/
$this->console->info('Skip load as feed is cached');
}
$json = json_decode(file_get_contents($file), true);
/*i*/
$this->console->label('Feed data')->log($json);
return $json;
}
示例7: spl_autoload_register
}
spl_autoload_register('Autoloader::load');
$plugins = FirePHP::to("plugin");
// assumes class (second argument) can be loaded by autoloader
$plugin = $plugins->plugin('PageControls1', 'FirePHP_Examples_PageControls1_Plugin');
$plugin->getInstance()->sendSimpleMessage(array("Second" => "Message"));
$plugins = FirePHP::to("plugin");
$plugin = $plugins->plugin('PageControls1');
/* NOTE: This is commented out as it will throw (multiple registrations for same plugin) but illustrates how it an be used
$plugin->register(array(
'class' => 'FirePHP_Examples_PageControls1_Plugin',
'file' => dirname(__FILE__) . '/plugins/PageControls1/lib/Plugin.php'
));
*/
$plugin->getInstance()->sendSimpleMessage(array("Third" => "Message"));
$plugins = FirePHP::to("plugin");
$plugin = $plugins->plugin('PageControls1');
// assumes class (second argument) can be loaded by autoloader
/* NOTE: This is commented out as it will throw (multiple registrations for same plugin) but illustrates how it an be used
$plugin->register(array(
'class' => 'FirePHP_Examples_PageControls1_Plugin'
));
*/
$plugin->getInstance()->sendSimpleMessage(array("Fourth" => "Message"));
$plugins = FirePHP::to("plugin");
$plugin = $plugins->plugin('PageControls1');
// this works because
// * $plugins->plugin('PageControls1', 'FirePHP_Examples_PageControls1_Plugin') or
// * $plugin->register()
// was called above
$plugin->getInstance()->sendSimpleMessage(array("Fifth" => "Message"));
示例8: sendSimpleMessage
public function sendSimpleMessage($message)
{
FirePHP::to('plugin')->plugin($this->alias)->sendSimpleMessage($message);
}
示例9: define
<?php
// NOTE: You must have FirePHP Companion installed (http://www.christophdorn.com/Tools/)
// See FirePHP Companion for result
define('INSIGHT_CONFIG_PATH', dirname(dirname(dirname(__FILE__))) . DIRECTORY_SEPARATOR . 'package.json');
require_once 'FirePHP/Init.php';
FirePHP::to('controller')->triggerClientTest(json_decode($_POST['payload']));
示例10: define
<?php
// NOTE: You must have FirePHP Companion installed (http://www.christophdorn.com/Tools/)
// See FirePHP Companion and Firebug Console for result
define('INSIGHT_CONFIG_PATH', dirname(dirname(dirname(__FILE__))) . DIRECTORY_SEPARATOR . 'package.json');
require_once 'FirePHP/Init.php';
$firephp = FirePHP::plugin("firephp");
$firephp->declareP();
p('Hey there Firebug Console', 'Variable Label');
$firephp->declareP('Ad-hock', true);
p('Hey there Ad-hock Console', 'Variable Label');
$console = FirePHP::to('request')->console('Debug');
$firephp->declareP($console, true);
p('Hey there Debug Console', 'Variable Label');
示例11: FirePHP__main
function FirePHP__main()
{
$activate = true;
$force = false;
if (defined('FIREPHP_ACTIVATED')) {
if (constant('FIREPHP_ACTIVATED') === false) {
$activate = false;
} else {
if (constant('FIREPHP_ACTIVATED') === true) {
$activate = true;
$force = true;
}
}
}
if ($activate && $force === false) {
// Only activate FirePHP if certain header prefixes are found:
// * x-wf-
// * x-insight
$headers = false;
if (function_exists('getallheaders')) {
$headers = getallheaders();
} else {
$headers = $_SERVER;
}
$activate = false;
foreach ($headers as $name => $value) {
$name = strtolower($name);
if (substr($name, 0, 5) == 'http_') {
$name = str_replace(' ', '-', str_replace('_', ' ', substr($name, 5)));
}
if (substr($name, 0, 5) == 'x-wf-') {
$activate = true;
} else {
if (substr($name, 0, 9) == 'x-insight') {
$activate = true;
}
}
}
}
if ($activate) {
if (!defined('FIREPHP_ACTIVATED')) {
define('FIREPHP_ACTIVATED', true);
}
// TODO: This may be removed in future?
set_include_path(get_include_path() . PATH_SEPARATOR . dirname(dirname(__FILE__)));
spl_autoload_register('FirePHP__autoload');
if (class_exists('FirePHP', false)) {
throw new Exception("The FirePHP class must not be loaded manually!");
}
// NOTE: We need to load this class here so we can get access to the FirePHP class
FirePHP__autoload('FirePHP_Insight');
// ensure the FirePHP class included has the correct version
$version = '0.3';
// @pinf replace '0.3' with '%%package.version%%'
if (FirePHP::VERSION != $version) {
throw new Exception("The included FirePHP class has the wrong version! This is likely due to an old version of FirePHP still being on the include path. The old version must be removed or the FirePHP 1.0 classes must have precedence on the include path!");
}
FirePHP::setInstance(new FirePHP_Insight());
if ($force === true) {
$GLOBALS['INSIGHT_FORCE_ENABLE'] = true;
}
Insight_Helper__main();
FirePHP::getInstance(true)->setLogToInsightConsole(FirePHP::to('page')->console());
} else {
if (!defined('FIREPHP_ACTIVATED')) {
define('FIREPHP_ACTIVATED', false);
}
class FirePHP
{
const VERSION = '0.3';
// @pinf replace '0.3' with '%%package.version%%'
const LOG = 'LOG';
const INFO = 'INFO';
const WARN = 'WARN';
const ERROR = 'ERROR';
const DUMP = 'DUMP';
const TRACE = 'TRACE';
const EXCEPTION = 'EXCEPTION';
const TABLE = 'TABLE';
const GROUP_START = 'GROUP_START';
const GROUP_END = 'GROUP_END';
protected static $instance = null;
public static function getInstance()
{
if (!self::$instance) {
self::$instance = new FirePHP();
}
return self::$instance;
}
public function getEnabled()
{
return false;
}
public function detectClientExtension()
{
return false;
}
public static function to()
{
return self::getInstance();
//.........这里部分代码省略.........
示例12: init
public static function init($configPath, $additionalConfig, $options = array())
{
if (self::$instance) {
throw new Exception("Insight_Helper already initialized!");
}
try {
// ensure min php version
if (version_compare(phpversion(), '5.1') == -1) {
throw new Exception('PHP version 5.1+ required. Your version: ' . phpversion());
}
// environment cleanup
unset($GLOBALS['INSIGHT_AUTOLOAD']);
unset($GLOBALS['INSIGHT_ADDITIONAL_CONFIG']);
unset($GLOBALS['INSIGHT_FORCE_ENABLE']);
$config = new Insight_Config();
if (is_array($configPath)) {
$config->loadFromArray($configPath, $additionalConfig);
} else {
$config->loadFromFile($configPath, $additionalConfig);
}
self::$instance = new self();
self::$instance->setConfig($config);
self::$instance->authorized = self::$instance->isClientAuthorized();
self::$instance->forceEnabled = isset($options['forceEnable']) && $options['forceEnable'] === true ? true : false;
if (self::$instance->authorized || self::$instance->forceEnabled) {
// set a dummy channel if not authorized
// this will prevent all data from being sent while keeping all channel logic and listeners working
if (self::$instance->authorized !== true) {
self::$instance->channel = new Wildfire_Channel_Memory();
}
// ensure cache path works
$cachePath = $config->getCachePath();
if (!file_exists($cachePath)) {
$baseCachePath = $config->getCachePath(true);
if (!is_writable($baseCachePath)) {
throw new Exception('Error creating cache path. Insufficient permissions. Directory not writable: ' . $baseCachePath);
}
if (!mkdir($cachePath, 0775, true)) {
throw new Exception('Error creating cache path at: ' . $cachePath);
}
}
if (!is_dir($cachePath)) {
throw new Exception('Cache path not a directory: ' . $cachePath);
}
if (!is_writable($cachePath)) {
throw new Exception('Cache path not writable: ' . $cachePath);
}
// enable output buffering to disable flush() calls in code
if (php_sapi_name() != 'cli') {
ob_start();
}
// always enable insight for now
self::$instance->setEnabled(true);
// flush on shutdown
register_shutdown_function('Insight_Helper__shutdown');
// set transport
// NOTE: If running as CLI we don't need to keep data in file
$transport = false;
if (php_sapi_name() != 'cli') {
$transport = new Insight_Transport();
$transport->setConfig($config);
self::$instance->getChannel()->setTransport($transport);
}
// initialize server
self::$instance->server = new Insight_Server();
self::$instance->server->setHelper(self::$instance);
self::$instance->server->setConfig($config);
// NOTE: This may stop script execution if a transport data request is detected
if ($transport) {
$transport->setServer(self::$instance->server);
if ($transport->listen() === true) {
self::$swallowDebugMessages = true;
exit;
}
}
// NOTE: This may stop script execution if a server request is detected
if (self::$instance->server->listen() === true) {
self::$swallowDebugMessages = true;
exit;
}
// initialize request object
self::$instance->request = new Insight_Request();
self::$instance->request->setConfig($config);
if ($clientInfo = self::$instance->getClientInfo()) {
self::$instance->request->setClientKey(implode(':', $clientInfo['authkeys']));
}
self::$instance->request->initAppRequest($_SERVER);
// send package info
// TODO: Figure out a way to not send this all the time
// Could be done via static data structures with checksums where the client announces which
// data structures it has by sending the checksum in the request headers
if ($packageInfo = $config->getPackageInfo()) {
self::to('package')->setInfo($packageInfo);
}
// self::to('controller')->setServerUrl(self::$instance->server->getUrl());
// init some plugins so their shutdown callback will be called
self::to('request')->files();
// setup error and assertion tracking
self::plugin('assertion')->onAssertionError(FirePHP::to('page')->console('Assertions'));
self::plugin('error')->onError(FirePHP::to('page')->console('Errors'));
//.........这里部分代码省略.........
示例13: show
public function show()
{
FirePHP::to('controller')->triggerInspect(array('target' => $this->message->meta['target']));
}
示例14: Wildfire_Channel_Memory
require_once 'Wildfire/Channel/Memory.php';
$memoryChannel = new Wildfire_Channel_Memory();
$receiver = new Receiver();
$receiver->setChannel($memoryChannel);
// listen to messages intended for the 'page' context
$receiver->addId('http://registry.pinf.org/cadorn.org/insight/@meta/receiver/console/page/0');
// listen to messages intended for the 'request' context
$receiver->addId('http://registry.pinf.org/cadorn.org/insight/@meta/receiver/console/request/0');
$memoryChannel->parseReceived($headers);
}
require_once 'Wildfire/Receiver.php';
class Receiver extends Wildfire_Receiver
{
public function getProtocol()
{
// TODO: return "*" so all protocols are captured?
return 'http://registry.pinf.org/cadorn.org/wildfire/@meta/protocol/component/0.1.0';
}
public function onMessageReceived(Wildfire_Message $message)
{
echo '<pre>';
var_dump($message->getReceiver());
var_dump(json_decode($message->getMeta(), true));
var_dump(json_decode($message->getData(), true));
echo '</pre>';
}
}
$console = FirePHP::to('page')->console();
$console->label('Label 1')->log('Hello World 1');
$console = FirePHP::to('request')->console();
$console->label('Label 2')->log('Hello World 2');
示例15: define
<?php
define('INSIGHT_CONFIG_PATH', dirname(dirname(dirname(__FILE__))) . DIRECTORY_SEPARATOR . 'package.json');
require_once 'FirePHP/Init.php';
$console = FirePHP::to('page')->console();
$console->label('The Label')->log('Hello World');
$console->label('A Variable')->log($_GET);