예제 #1
0
<?php

namespace PMVC\PlugIn\debug;

use PMVC as p;
${_INIT_CONFIG}[_CLASS] = __NAMESPACE__ . '\\debug_cli';
p\initPlugin(['debug' => null], true);
class debug_cli extends p\PlugIn implements DebugDumpInterface
{
    public function init()
    {
        if (!isset($this['level'])) {
            $this['level'] = 'debug';
        }
    }
    public function escape($s)
    {
        return strtr($s, ["\n" => '', "\r" => '']);
    }
    public function getColor($level)
    {
        $levels = ['trace' => '%y', 'debug' => '%g', 'info' => '%b', 'warn' => '%m', 'error' => '%r'];
        if (isset($levels[$level])) {
            return $levels[$level];
        } else {
            return '%c';
        }
    }
    public function dump($p, $type = 'debug')
    {
        $cli = p\plug('cli');
예제 #2
0
<?php

namespace PMVC\PlugIn\debug;

use PMVC as p;
${_INIT_CONFIG}[_CLASS] = __NAMESPACE__ . '\\debug_console';
p\initPlugin(['debug' => null]);
class debug_console extends p\PlugIn implements DebugDumpInterface
{
    private $bInitJs = false;
    private function getStatic()
    {
        if ($this->bInitJs) {
            return p\plug('asset');
        }
        $this->bInitJs = true;
        $static = p\plug('asset');
        $static->importJs('//cdn-htlovestory.netdna-ssl.com/lib/dlog/dlog.min.1.js');
        $static->js("var log = new dlog({ level: 'trace'});");
        return $static;
    }
    public function escape($string)
    {
        if (!empty($string) && is_string($string)) {
            return strtr($string, array('\\' => '\\\\', "'" => "\\'", '"' => '\\"', "\r" => '\\r', "\n" => '\\n', '</' => '<\\/'));
        }
    }
    public function dump($p, $type = null)
    {
        $json_str = json_encode($p);
        $static = $this->getStatic();
예제 #3
0
파일: test.php 프로젝트: pmvc-plugin/curl
 function setup()
 {
     \PMVC\initPlugin(['curl' => null], true);
 }
예제 #4
0
<?php

/**
 * Debug Store use with view engine.
 */
namespace PMVC\PlugIn\debug;

use PMVC\Event;
use PMVC as p;
use UnderflowException;
${_INIT_CONFIG}[_CLASS] = __NAMESPACE__ . '\\debug_store';
p\initPlugin(['debug' => null, 'controller' => null]);
/**
 * @parameters numeric level Debug dump level 
 */
class debug_store extends p\PlugIn implements DebugDumpInterface
{
    private $_view;
    public function init()
    {
        p\callPlugin('dispatcher', 'attach', [$this, Event\SET_CONFIG . '_' . _FORWARD]);
        p\callPlugin('dispatcher', 'attach', [$this, Event\FINISH]);
        if (!isset($this['level'])) {
            $this['level'] = 'trace';
        }
    }
    public function onSetConfig__forward_()
    {
        $c = p\plug('controller');
        $view = $this->_getView();
        if (!empty($view->get('debugs')) && 'redirect' === $c[_FORWARD]->getType()) {