本文整理汇总了PHP中Cake\Error\Debugger类的典型用法代码示例。如果您正苦于以下问题:PHP Debugger类的具体用法?PHP Debugger怎么用?PHP Debugger使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Debugger类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _outputMessage
protected function _outputMessage($template)
{
$error = $this->controller->viewVars['error'];
$data = [];
$data['class'] = 'Error';
$data['code'] = $error->getCode();
$data['url'] = '/' . $this->controller->request->url;
$data['message'] = $error->getMessage();
$data['errors'] = $this->controller->viewVars['errors'];
if (Configure::read('debug')) {
$data['DEBUG']['trace'] = Debugger::formatTrace($error->getTrace(), ['format' => 'array', 'args' => false]);
$queryLog = $this->_getQueryLog();
if ($queryLog) {
$data['DEBUG']['queryLog'] = $queryLog;
}
}
$jsonOptions = JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_AMP | JSON_HEX_QUOT;
if (Configure::read('debug')) {
$jsonOptions = $jsonOptions | JSON_PRETTY_PRINT;
}
$this->controller->response->type('json');
$this->controller->response->body(json_encode($data, $jsonOptions));
$this->controller->response->statusCode($data['code']);
return $this->controller->response;
}
示例2: __construct
/**
* {@inheritDoc}
*/
public function __construct(array $config = [])
{
if (Configure::read('debug')) {
Debugger::checkSecurityKeys();
}
parent::config($config);
}
示例3: _createStreamDataWithEntity
public function _createStreamDataWithEntity($entity, $entity_type)
{
// if(!$entity_type){
// $entity_type = get_class($entity);
// }
$entity_type_p = $entity_type . 's';
// debug($entity);
// $game = $this->_contains($game)->first();
$success = $entity->format(null, 'feed_push');
if (!$success) {
Debugger::log('It failed after formatting the game');
return false;
}
$base_data = ["object" => $entity_type . ":" . $entity->id, 'type' => "feed-" . strtolower($entity_type_p), 'foreign_id' => $entity_type . ":" . $entity->id, 'display' => $entity->display];
if ($entity_type == 'Game') {
$specific_data = ["verb" => strtolower($entity->game_type_name), 'first_user_image' => $entity->winner_image, 'first_user_id' => $entity->winner_id, 'first_user_score' => $entity->winner_points, 'second_user_image' => $entity->loser_image, 'second_user_id' => $entity->loser_id, 'second_user_score' => $entity->loser_points, 'game_type_name' => $entity->game_type_name, 'time' => $entity->created];
} else {
if ($entity_type == 'Friendship') {
$specific_data = ["verb" => "friend", 'first_user_id' => $entity->first_user_id, 'first_user_image' => $entity->first_user_image, 'second_user_id' => $entity->second_user_id, 'second_user_image' => $entity->second_user_image, 'time' => $entity->modified];
} else {
return false;
}
}
$base_data = array_merge($base_data, $specific_data);
return $base_data;
}
示例4: start
/**
* Start an benchmarking timer.
*
* @param string $name The name of the timer to start.
* @param string $message A message for your timer
* @return boolean Always true
*/
public static function start($name = null, $message = null)
{
$start = microtime(true);
if (!$name) {
$named = false;
$calledFrom = debug_backtrace();
$_name = $name = Debugger::trimpath($calledFrom[0]['file']) . ' line ' . $calledFrom[0]['line'];
} else {
$named = true;
}
if (!$message) {
$message = $name;
}
$_name = $name;
$i = 1;
while (isset(self::$_timers[$name])) {
$i++;
$name = $_name . ' #' . $i;
}
if ($i > 1) {
$message .= ' #' . $i;
}
self::$_timers[$name] = array('start' => $start, 'message' => $message, 'named' => $named);
return true;
}
示例5: addCall
/**
* Add a HTTP call to the data
*
* @param Request $request Call request
* @param Response $response Call response
* @param float $time duration of the call
*/
public static function addCall($request, $response, $time = null)
{
$calls = static::config('calls');
$trace = Debugger::trace(['start' => 2]);
$calls[] = ['request' => ['uri' => (string) $request->getUri(), 'body' => $request->body(), 'method' => $request->getMethod(), 'headers' => $request->getHeaders(), 'content-type' => $request->getHeader('Content-Type')], 'response' => ['body' => $response->body(), 'status_code' => $response->getStatusCode(), 'headers' => $response->getHeaders(), 'content-type' => $response->getHeader('Content-Type')], 'time' => $time, 'trace' => $trace];
static::drop('calls');
static::config('calls', $calls);
}
示例6: getHtml
/**
* get the body for htmll message
*
* @access private
* @author sakuragawa
*/
private function getHtml($message, $file, $line, $context = null)
{
$params = Router::getRequest();
$trace = Debugger::trace(array('start' => 2, 'format' => 'base'));
$session = isset($_SESSION) ? $_SESSION : array();
$msg = array('<p><strong>', $message, '</strong></p>', '<p>', $file . '(' . $line . ')', '</p>', '', '<h2>', 'Backtrace:', '</h2>', '', '<pre>', self::dumper($trace), '</pre>', '', '<h2>', 'Request:', '</h2>', '', '<h3>URL</h3>', $this->url(), '<h3>Client IP</h3>', $this->getClientIp(), '<h3>Referer</h3>', env('HTTP_REFERER'), '<h3>Parameters</h3>', self::dumper($params), '<h3>Cake root</h3>', APP, '', '<h2>', 'Environment:', '</h2>', '', self::dumper($_SERVER), '', '<h2>', 'Session:', '</h2>', '', self::dumper($session), '', '<h2>', 'Cookie:', '</h2>', '', self::dumper($_COOKIE), '', '<h2>', 'Context:', '</h2>', '', self::dumper($context), '');
return join("", $msg);
}
示例7: addCall
/**
* Add a HTTP call to the data
*
* @param $request
* @param $response
* @param $time
*/
public static function addCall($request, $response, $time = null)
{
$calls = static::config('calls');
$trace = Debugger::trace(['start' => 2]);
$calls[] = ['request' => $request, 'response' => $response, 'time' => $time, 'trace' => $trace];
static::drop('calls');
static::config('calls', $calls);
}
示例8: change
/**
* Change Method.
*
* Write your reversible migrations using this method.
*
* More information on writing migrations is available here:
* http://docs.phinx.org/en/latest/migrations.html#the-abstractmigration-class
*
* @return void
*/
public function change()
{
$table = $this->table('queued_tasks');
try {
$adapter = new MysqlAdapter([]);
if ($adapter->getSqlType('text', 'longtext')) {
$table->changeColumn('data', 'text', ['limit' => MysqlAdapter::TEXT_LONG, 'null' => true, 'default' => null]);
}
} catch (Exception $e) {
Debugger::dump($e->getMessage());
}
}
示例9: createAdmin
/**
* @param string $userId
* @return bool
*/
public function createAdmin($userId)
{
$teamMembership = TableRegistry::get('TeamMemberships');
$adminship = new TeamMembership(['role' => 'admin', 'team_id' => $this->id, 'member_id' => $userId]);
$isCurrentMember = $teamMembership->find()->where(['member_id' => $userId, 'team_id' => $this->id])->first();
Debugger::log($isCurrentMember);
if (!empty($isCurrentMember)) {
$adminship->id = $isCurrentMember->id;
}
if (!$teamMembership->save($adminship)) {
return false;
}
return true;
}
示例10: _getErrorData
/**
* Helper method used to generate extra debugging data into the error template
*
* @return array debugging data
*/
protected function _getErrorData()
{
$data = [];
$viewVars = $this->controller->viewVars;
if (!empty($viewVars['_serialize'])) {
foreach ($viewVars['_serialize'] as $v) {
$data[$v] = $viewVars[$v];
}
}
if (!empty($viewVars['error']) && Configure::read('debug')) {
$data['exception'] = ['class' => get_class($viewVars['error']), 'code' => $viewVars['error']->getCode(), 'message' => $viewVars['error']->getMessage()];
if (!isset($data['trace'])) {
$data['trace'] = Debugger::formatTrace($viewVars['error']->getTrace(), ['format' => 'array', 'args' => false]);
}
}
return $data;
}
示例11: main
/**
* Make tasks callable
*
* @return void
*/
public function main()
{
if (!empty($this->params['dry-run'])) {
$this->out('<warning>Dry-run mode enabled!</warning>', 1, Shell::QUIET);
}
$exclude = ['.git', '.svn', 'vendor', 'Vendor', 'webroot', 'tmp', 'logs'];
if (empty($this->params['plugin']) && !empty($this->params['namespace']) && $this->params['namespace'] === 'App') {
$exclude[] = 'plugins';
$exclude[] = 'Plugin';
}
$files = $this->Stage->files($exclude);
foreach ($files as $file) {
$this->out(sprintf('<info>Processing %s</info>', Debugger::trimPath($file)));
$this->process($file);
}
$this->Stage->commit();
}
示例12: record
/**
* Stores a memory point in the internal tracker.
* Takes a optional message name which can be used to identify the memory point.
* If no message is supplied a debug_backtrace will be done to identify the memory point.
*
* @param string $message Message to identify this memory point.
* @return bool
*/
public static function record($message = null)
{
$memoryUse = self::getCurrent();
if (!$message) {
$trace = debug_backtrace();
$message = Debugger::trimPath($trace[0]['file']) . ' line ' . $trace[0]['line'];
}
if (isset(self::$_points[$message])) {
$originalMessage = $message;
$i = 1;
while (isset(self::$_points[$message])) {
$i++;
$message = $originalMessage . ' #' . $i;
}
}
self::$_points[$message] = $memoryUse;
return true;
}
示例13: all
/**
* All command.
*
* @return void
*/
public function all()
{
if (!empty($this->params['dry-run'])) {
$this->out('<warning>Dry-run mode enabled!</warning>', 1, Shell::QUIET);
}
$exclude = ['.git', '.svn', 'vendor', 'Vendor', 'webroot', 'tmp', 'logs'];
if (empty($this->params['plugin']) && !empty($this->params['namespace']) && $this->params['namespace'] === 'App') {
$exclude[] = 'plugins';
$exclude[] = 'Plugin';
}
$files = $this->Stage->files($exclude);
$actions = $this->_getActions();
foreach ($actions as $action) {
$this->out(sprintf('<info>*** Upgrade step %s ***</info>', $action));
if (!empty($this->params['interactive'])) {
$continue = $this->in('Continue with `' . $action . '`?', array('y', 'n', 'q'), 'y');
if ($continue === 'q') {
return $this->error('Aborted. Changes are not commited.');
}
if ($continue === 'n') {
$this->out('Skipping this step.');
continue;
}
}
foreach ($files as $file) {
$this->out(sprintf('<info> * Processing %s</info>', Debugger::trimPath($file)), 1, Shell::VERBOSE);
$this->{$action}->Stage = $this->Stage;
$this->{$action}->process($file);
if (!empty($this->params['interactive'])) {
$this->Stage->commit();
$this->Stage->clear();
}
}
}
if (empty($this->params['interactive'])) {
$this->Stage->commit();
}
}
示例14: import
public function import()
{
if ($this->request->is('post')) {
if ($this->request->data['submissionFile'] == '') {
$this->set('file_status', 'No file submitted, try again.');
} elseif ($this->request->data['submissionFile']) {
$this->set('file_status', 'File submitted.');
Debugger::dump($this->request->data['submissionFile']);
Debugger::dump($this->request->data['table']);
if ($this->request->data['table'] == 0) {
Debugger::dump($this->request->data['submissionFile']);
} elseif ($this->request->data['table'] == 1) {
} elseif ($this->request->data['table'] == 2) {
} else {
$this->Flash->error('Unexpected table value');
}
$this->Flash->success('File successfully uploaded, Importing...');
} else {
$this->set('file_status', 'Please submit a file.');
}
} else {
$this->set('file_status', 'Please submit a file.');
}
}
示例15: debug
/**
* Prints out debug information about given variable.
*
* Only runs if debug level is greater than zero.
*
* @param boolean $var Variable to show debug information for.
* @param boolean $showHtml If set to true, the method prints the debug data in a browser-friendly way.
* @param boolean $showFrom If set to true, the method prints from where the function was called.
* @return void
* @link http://book.cakephp.org/2.0/en/development/debugging.html#basic-debugging
* @link http://book.cakephp.org/2.0/en/core-libraries/global-constants-and-functions.html#debug
*/
public static function debug($var, $showHtml = null, $showFrom = true)
{
if (Configure::read('debug') > 0) {
// App::uses('Debugger', 'Utility');
$file = '';
$line = '';
$lineInfo = '';
if ($showFrom) {
$trace = Debugger::trace(array('start' => 1, 'depth' => 2, 'format' => 'array'));
$file = str_replace(array(CAKE_CORE_INCLUDE_PATH, ROOT), '', $trace[0]['file']);
$line = $trace[0]['line'];
}
$html = <<<HTML
<div class="cake-debug-output">
<pre class="cake-debug">
%s
</pre>
</div>
HTML;
$text = <<<TEXT
%s
########## DEBUG ##########
%s
###########################
TEXT;
$template = $html;
if (php_sapi_name() === 'cli' || $showHtml === false) {
$template = $text;
if ($showFrom) {
$lineInfo = sprintf('%s (line %s)', $file, $line);
}
}
if ($showHtml === null && $template !== $text) {
$showHtml = true;
}
$var = Debugger::exportVar($var, 25);
if ($showHtml) {
$template = $html;
$var = htmlspecialchars($var);
if ($showFrom) {
$lineInfo = sprintf('<span><strong>%s</strong> (line <strong>%s</strong>)</span>', $file, $line);
}
}
printf($template, $var);
}
}