From 2cfeb0283cb9d2343556aa9686c89b100a449ef3 Mon Sep 17 00:00:00 2001 From: Akihito Koriyama Date: Mon, 21 Jan 2019 17:14:44 +0900 Subject: [PATCH 01/21] remove firePHP --- Panda.php | 49 ++----------------------------------------------- 1 file changed, 2 insertions(+), 47 deletions(-) diff --git a/Panda.php b/Panda.php index cd8c692..59525f5 100644 --- a/Panda.php +++ b/Panda.php @@ -16,14 +16,6 @@ * debuglib for PHP5 * Thomas Schüßler * http://phpdebuglib.de/ - * - * FireBug - * http://www.getfirebug.com/ - * - * FirePHP - * http://www.christophdorn.com/ - * https://addons.mozilla.org/ja/firefox/addon/6149 - * http://www.firephp.org/ */ // for 5.2.x or earlier @@ -118,6 +110,7 @@ class Panda * config callback on fire * * @var string + * @deprecated */ const CONFIG_ON_ERROR_FIRED = 'on_error'; @@ -139,6 +132,7 @@ class Panda * config - use firephp ? * * @var string + * @deprecated */ const CONFIG_ENABLE_FIREPHP = 'firephp'; @@ -350,10 +344,6 @@ function p($v = ''){ } set_exception_handler(array('Panda', 'onException')); } else { - if (self::$_config[self::CONFIG_ENABLE_FIREPHP]) { - include_once 'FirePHPCore/FirePHP.class.php'; - include_once 'FirePHPCore/fb.php'; - } self::_initOnDebug(); if (self::$_config[self::CONFIG_CATCH_FATAL] === true) { ob_start(array('Panda', 'onFatalError')); @@ -377,7 +367,6 @@ private static function _initOnDebug() require_once 'Panda/Debug.php'; require_once 'Panda/Debug/util.php'; require_once 'Panda/Exception.php'; - include_once 'Net/Growl.php'; ini_set('display_errors', 1); // アサーションを有効 assert_options(ASSERT_ACTIVE, 1); @@ -743,18 +732,6 @@ public static function error($heading, $subheading = "", $info = "", array $opti if (self::$_config[self::CONFIG_DEBUG] !== true) { return; } - if (isset($_SERVER['HTTP_X_REQUESTED_WITH']) && $_SERVER['HTTP_X_REQUESTED_WITH'] === 'XMLHttpRequest') { - if (class_exists('FB', false)) { - $in = isset($options['file']) ? "- in {$options['file']} on line {$options['line']}" : ''; - $msg = "$heading - {$subheading} $in"; - if ($info) { - FB::group($msg); - FB::error($info); - FB::groupEnd(); - return; - } - } - } static $num = 1; //div id number $heading = (is_numeric($heading)) ? self::$packageName[$heading] : $heading; // Application error callback @@ -762,24 +739,6 @@ public static function error($heading, $subheading = "", $info = "", array $opti call_user_func(self::$_config[self::CONFIG_ON_ERROR_FIRED], $heading, $subheading, $info, $options); } $fileInfoString = isset($options['file']) ? "in {$options['file']} on line {$options['line']}" : 'in unknown file'; - if (self::$_config[self::CONFIG_ENABLE_FIREPHP] && isset($options['severity'])) { - $fireLevel = FirePHP::ERROR; - switch (true) { - case ($options['severity'] == E_WARNING || $options['severity'] == E_USER_WARNING) : - $fireLevel = FirePHP::WARN; - break; - case ($options['severity'] == E_NOTICE || $options['severity'] == E_USER_NOTICE) : - $fireLevel = FirePHP::INFO; - break; - case ($options['severity'] == E_STRICT) : - $fireLevel = FirePHP::LOG; - break; - default : - $fireLevel = FirePHP::ERROR; - break; - } - FB::send("{$subheading} - {$fileInfoString}", $heading, $fireLevel); - } self::GrowlNotify($heading, $subheading . "\n{$fileInfoString}"); $defaultOptions = array('file' => null, 'line' => null, @@ -1085,10 +1044,6 @@ public static function onFatalError($buffer) // Web header("HTTP/1.x 503 Service Temporarily Unavailable."); $id = substr(md5(serialize($error)), 0, 6); - // FB - if (self::$_config[self::CONFIG_DEBUG] === true && self::$_config[self::CONFIG_ENABLE_FIREPHP]) { - FB::error("Fatal Error - {$error['message']} - ref# {$id}"); - } // write fatal error in file if (self::$_config[self::CONFIG_LOG_PATH]) { $path = self::$_config[self::CONFIG_LOG_PATH]; From 121c69642c0c35c5148dac6b5434757e575d597b Mon Sep 17 00:00:00 2001 From: Akihito Koriyama Date: Mon, 21 Jan 2019 17:15:59 +0900 Subject: [PATCH 02/21] remove Growl --- Panda.php | 23 ++--------------------- 1 file changed, 2 insertions(+), 21 deletions(-) diff --git a/Panda.php b/Panda.php index 59525f5..590d9b3 100644 --- a/Panda.php +++ b/Panda.php @@ -168,6 +168,7 @@ class Panda * config for growl * * @var string + * @deprecated */ const CONFIG_GROWL = 'growl'; @@ -739,7 +740,6 @@ public static function error($heading, $subheading = "", $info = "", array $opti call_user_func(self::$_config[self::CONFIG_ON_ERROR_FIRED], $heading, $subheading, $info, $options); } $fileInfoString = isset($options['file']) ? "in {$options['file']} on line {$options['line']}" : 'in unknown file'; - self::GrowlNotify($heading, $subheading . "\n{$fileInfoString}"); $defaultOptions = array('file' => null, 'line' => null, 'trace' => array(), @@ -806,29 +806,10 @@ public static function error($heading, $subheading = "", $info = "", array $opti /** * Growl notify - * - * This needs. - * - * 1) Growl installation. - * 2) Growl setting for remote application acception. - * - * @param string $title - * @param string $description + * @deprecated */ public static function growlNotify($title, $description) { - static $growlApp; - - if (self::CONFIG_GROWL !== true) { - return; - } - - if (!$growlApp) { - $growlApp = new Net_Growl_Application('Panda', array('Panda_Growl_Notify')); - } - $growl = Net_Growl::singleton($growlApp, null, null); - $growl->setNotificationLimit(16); - $result = $growl->notify('Panda_Growl_Notify', $title, $description); } /** From 8b581d4f111352ceb8833749c02a291166a9ce88 Mon Sep 17 00:00:00 2001 From: Akihito Koriyama Date: Mon, 21 Jan 2019 17:16:55 +0900 Subject: [PATCH 03/21] yaer 2019 --- Panda.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Panda.php b/Panda.php index 590d9b3..402b9c1 100644 --- a/Panda.php +++ b/Panda.php @@ -8,7 +8,7 @@ * @category Panda * @package Panda * @author Akihito Koriyama - * @copyright 2009 Akihito Koriyama All rights reserved. + * @copyright 2009-2019 Akihito Koriyama All rights reserved. * @license http://opensource.org/licenses/bsd-license.php BSD * @version SVN: Release: v.0.1.0 $Id: Panda.php 97 2009-10-08 03:45:58Z koriyama@users.sourceforge.jp $ * @link n/a @@ -42,7 +42,7 @@ * @category Panda * @package Panda * @author Akihito Koriyama - * @copyright 2008 Akihito Koriyama All rights reserved. + * @copyright 2009-2019 Akihito Koriyama All rights reserved. * @license http://opensource.org/licenses/bsd-license.php BSD * @version SVN: Release: $Id: Panda.php 97 2009-10-08 03:45:58Z koriyama@users.sourceforge.jp $ * @link http://api.Panda-project.net/Panda/Panda.html From ab2f012385641753e9b3844447e5ba68929b766d Mon Sep 17 00:00:00 2001 From: Akihito Koriyama Date: Mon, 21 Jan 2019 17:18:01 +0900 Subject: [PATCH 04/21] remove require --- Panda.php | 3 --- 1 file changed, 3 deletions(-) diff --git a/Panda.php b/Panda.php index 402b9c1..97fc4cf 100644 --- a/Panda.php +++ b/Panda.php @@ -365,9 +365,6 @@ function p($v = ''){ */ private static function _initOnDebug() { - require_once 'Panda/Debug.php'; - require_once 'Panda/Debug/util.php'; - require_once 'Panda/Exception.php'; ini_set('display_errors', 1); // アサーションを有効 assert_options(ASSERT_ACTIVE, 1); From b15964f6d2be9d3abf7205d2774b09082d328ea2 Mon Sep 17 00:00:00 2001 From: Akihito Koriyama Date: Mon, 21 Jan 2019 17:18:33 +0900 Subject: [PATCH 05/21] remove pre-php5.2 code (!) --- Panda.php | 6 ------ 1 file changed, 6 deletions(-) diff --git a/Panda.php b/Panda.php index 97fc4cf..26396da 100644 --- a/Panda.php +++ b/Panda.php @@ -18,12 +18,6 @@ * http://phpdebuglib.de/ */ -// for 5.2.x or earlier -if (!defined('E_DEPRECATED')) { - define('E_DEPRECATED', 8192); - define('E_USER_DEPRECATED', 16384); -} - /** * Panda Class * From 1247bc2fa4de228f519388bb83c6e1a311c01bab Mon Sep 17 00:00:00 2001 From: Akihito Koriyama Date: Mon, 21 Jan 2019 17:19:54 +0900 Subject: [PATCH 06/21] fix phpdoc --- Panda.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Panda.php b/Panda.php index 26396da..12f0381 100644 --- a/Panda.php +++ b/Panda.php @@ -806,9 +806,9 @@ public static function growlNotify($title, $description) /** * Message Output * - * @param string $heading - * @param message $subheading - * @param array $info + * @param string $heading + * @param string $subheading + * @param array $info * * @return void */ From bf369bcfaf24cb2f2117f9ada1ab4f899faeb835 Mon Sep 17 00:00:00 2001 From: Akihito Koriyama Date: Mon, 21 Jan 2019 17:23:11 +0900 Subject: [PATCH 07/21] dreprecated pear package version number --- Panda.php | 1 + 1 file changed, 1 insertion(+) diff --git a/Panda.php b/Panda.php index 12f0381..d73258d 100644 --- a/Panda.php +++ b/Panda.php @@ -45,6 +45,7 @@ class Panda { /** * Version + * @deprecated */ const VERSION = '0.3.44'; From 3058425321965d1cbb39290ad87fcf112682dc94 Mon Sep 17 00:00:00 2001 From: Akihito Koriyama Date: Tue, 22 Jan 2019 10:35:32 +0900 Subject: [PATCH 08/21] update phpdoc --- Panda.php | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/Panda.php b/Panda.php index d73258d..432d58e 100644 --- a/Panda.php +++ b/Panda.php @@ -45,7 +45,7 @@ class Panda { /** * Version - * @deprecated + * @deprecated */ const VERSION = '0.3.44'; @@ -218,7 +218,7 @@ class Panda /** * API check * - * @var + * @var string */ const CONFIG_IS_API_CHECK = 'is_api'; @@ -262,8 +262,7 @@ class Panda /** * PHP Error code statics * - * @var integer - * + * @var int */ private static $_errorStat = 0; @@ -435,7 +434,6 @@ public static function onStackError($error) * @param object $error PEAR Error object * * @return void - * @ignore */ public static function onPearError(PEAR_Error $error) { From a7460d32fd7d0b9240cc9cb694dcf7720b2324fc Mon Sep 17 00:00:00 2001 From: Akihito Koriyama Date: Tue, 22 Jan 2019 10:35:55 +0900 Subject: [PATCH 09/21] year 2019 --- LICENSE | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/LICENSE b/LICENSE index d706a0f..cd6dea1 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ Panda -Copyright (c) 2008-2018 Akihito Koriyama +Copyright (c) 2008-2019 Akihito Koriyama Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: From b5e3ea905a3473171e61f19192ffd19b3d07fa8d Mon Sep 17 00:00:00 2001 From: Akihito Koriyama Date: Tue, 22 Jan 2019 10:36:50 +0900 Subject: [PATCH 10/21] fix typo --- Panda/Debug/util.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Panda/Debug/util.php b/Panda/Debug/util.php index e7a4e0a..2ff3bfd 100644 --- a/Panda/Debug/util.php +++ b/Panda/Debug/util.php @@ -49,10 +49,10 @@ * Prints human-readable information about a variable with print location and variable name * * @param mixed $mixed variables - * @param formart $formart 'var' | 'export' | 'printa' | 'fire' | 'syslog' + * @param string $format 'var' | 'export' | 'printa' | 'fire' | 'syslog' * @param array $options */ -function p($mixed = null, $formart = 'dump', array $options = array()) +function p($mixed = null, $format = 'dump', array $options = array()) { if (PHP_SAPI === 'cli') { call_user_func('v', func_get_args()); @@ -67,7 +67,7 @@ function p($mixed = null, $formart = 'dump', array $options = array()) return; } $options['trace'] = debug_backtrace(); - Panda_Debug::p($mixed, $formart, $options); + Panda_Debug::p($mixed, $format, $options); } /** From a7d093d13a9e744a5485c6dee2fbeec6c4a7c1a1 Mon Sep 17 00:00:00 2001 From: Akihito Koriyama Date: Tue, 22 Jan 2019 10:37:49 +0900 Subject: [PATCH 11/21] remove firePHP --- Panda/Debug/util.php | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/Panda/Debug/util.php b/Panda/Debug/util.php index 2ff3bfd..866482f 100644 --- a/Panda/Debug/util.php +++ b/Panda/Debug/util.php @@ -229,16 +229,6 @@ function v($values = null) echo $colorOpenPlain . "in {$colorOpenBold}{$file}{$colorClose}{$colorOpenPlain} on line {$line}$method" . $colorClose . "\n"; return; } - $labelField = '
'; - $labelField .= '' . $label . ''; - if (class_exists('FB', false)) { - $label = 'p() in ' . $trace[0]['file'] . ' on line ' . $trace[0]['line']; - FB::group($label); - FB::error($values); - FB::groupEnd(); - return; - } $pre = "
";
     if ($varName != FALSE) {

From 3e3f4c9286d35511b53d15261ba8bb106d8f73da Mon Sep 17 00:00:00 2001
From: Akihito Koriyama 
Date: Tue, 22 Jan 2019 10:38:36 +0900
Subject: [PATCH 12/21] remove unused code

---
 Panda/Debug/util.php | 5 -----
 1 file changed, 5 deletions(-)

diff --git a/Panda/Debug/util.php b/Panda/Debug/util.php
index 866482f..06b1cbe 100644
--- a/Panda/Debug/util.php
+++ b/Panda/Debug/util.php
@@ -213,11 +213,6 @@ function v($values = null)
             $paramNum++;
         }
     }
-    $label = "$varName in {$file} on line {$line}$method";
-    if (strlen(serialize($values)) > 1000000) {
-        $ouputMode = 'dump';
-    }
-    $label = (is_object($values)) ? ucwords(get_class($values)) . " $label" : $label;
     // if CLI
     if (PHP_SAPI === 'cli') {
         $colorOpenReverse = "\033[7;32m";

From 84ad16cf1b87a6c2866439c75ed2d7d9777091aa Mon Sep 17 00:00:00 2001
From: Akihito Koriyama 
Date: Tue, 22 Jan 2019 10:40:19 +0900
Subject: [PATCH 13/21] update phpdoc

---
 Panda/Debug.php | 4 ----
 1 file changed, 4 deletions(-)

diff --git a/Panda/Debug.php b/Panda/Debug.php
index 241755d..99c83b4 100644
--- a/Panda/Debug.php
+++ b/Panda/Debug.php
@@ -34,7 +34,6 @@
  * @author    Akihito Koriyama 
  * @copyright 2008 Akihito Koriyama  All rights reserved.
  * @license   http://opensource.org/licenses/bsd-license.php BSD
- * @link      n/a
  *
  */
 
@@ -76,8 +75,6 @@ class Panda_Debug
 
     /**
      * new不可
-     *
-     * @ignore
      */
     private function __construct()
     {
@@ -472,7 +469,6 @@ public static function dump(&$var, $varName = false, $pInfo = false)
      * @author Akihito Koriyama
      *
      * @link http://www.php.net/manual/ja/function.var-dump.php#76072
-     * @ignore
      */
     private static function _doDump(&$var, $var_name = NULL, $indent = NULL, $reference = NULL)
     {

From 25e7e6fb56702c6f92bb87fe80a1e4f39b6c49b5 Mon Sep 17 00:00:00 2001
From: Akihito Koriyama 
Date: Tue, 22 Jan 2019 10:41:37 +0900
Subject: [PATCH 14/21] fix phpdoc

---
 Panda/Exception.php | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Panda/Exception.php b/Panda/Exception.php
index 0a61930..fdf7ac9 100644
--- a/Panda/Exception.php
+++ b/Panda/Exception.php
@@ -46,7 +46,7 @@ public function __construct($message, $httpStatus = 200, array $info = array())
     /**
      * Get error info
      *
-     * @return string
+     * @return array
      */
     public function getInfo()
     {

From d63a6ce3b4b2d5c49e118398cdd103452a281f1f Mon Sep 17 00:00:00 2001
From: Akihito Koriyama 
Date: Tue, 22 Jan 2019 16:01:49 +0900
Subject: [PATCH 15/21] Update composer.json

---
 composer.json | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/composer.json b/composer.json
index 487eab2..b779838 100644
--- a/composer.json
+++ b/composer.json
@@ -17,6 +17,6 @@
     },
     "autoload": {
         "classmap": ["Panda"],
-        "files": ["./Panda.php"]
+        "files": ["./Panda.php", "./Panda/Debug/util.php"]
     }
 }

From 934ce0175c9702ba5d1d4685547eb53fe5c44973 Mon Sep 17 00:00:00 2001
From: Akihito Koriyama 
Date: Tue, 22 Jan 2019 16:11:51 +0900
Subject: [PATCH 16/21] refactor example

---
 data/htdocs/__panda/edit/index.php            |  4 +-
 data/htdocs/panda_sample/__panda              |  1 +
 data/htdocs/panda_sample/index.php            |  5 +-
 data/htdocs/panda_sample/index.view.php       |  2 -
 data/htdocs/panda_sample/memory_error.php     |  3 +-
 data/htdocs/panda_sample/panda_exception.php  |  2 +-
 data/htdocs/panda_sample/panda_ini.php        | 48 +++++--------------
 data/htdocs/panda_sample/pear_error.php       |  8 +---
 .../panda_sample/uncaught_exception.php       |  2 +-
 data/htdocs/panda_sample/utility.php          |  2 +-
 10 files changed, 24 insertions(+), 53 deletions(-)
 create mode 120000 data/htdocs/panda_sample/__panda

diff --git a/data/htdocs/__panda/edit/index.php b/data/htdocs/__panda/edit/index.php
index e396c4e..01d7887 100644
--- a/data/htdocs/__panda/edit/index.php
+++ b/data/htdocs/__panda/edit/index.php
@@ -1,6 +1,6 @@
 
 	
  • panda debug function
  • -

    FirePHP supported.

    -

    firebug console error output on FireFox is also available, open firefox console after install FirePHP.

    diff --git a/data/htdocs/panda_sample/memory_error.php b/data/htdocs/panda_sample/memory_error.php index 784634b..cf5fd5f 100644 --- a/data/htdocs/panda_sample/memory_error.php +++ b/data/htdocs/panda_sample/memory_error.php @@ -1,5 +1,6 @@ time()); // show status page with specify http code diff --git a/data/htdocs/panda_sample/panda_ini.php b/data/htdocs/panda_sample/panda_ini.php index 9677d44..9bc8da7 100644 --- a/data/htdocs/panda_sample/panda_ini.php +++ b/data/htdocs/panda_sample/panda_ini.php @@ -1,40 +1,14 @@ true, // debug mode - Panda::CONFIG_VALID_PATH => array('/'), // valid path (user source code path) - Panda::CONFIG_LOG_PATH => '/tmp/', // log directory path - Panda::CONFIG_HTTP_TPL => __DIR__ . '/../../../Panda/templates/http.php', // custom Http error output template - Panda::CONFIG_FATAL_HTML => __DIR__ . '/../../../Panda/templates/fatal.php', // fatal error template - Panda::CONFIG_ON_ERROR_FIRED => array('Panda_App_Error_Handler', 'onError'), // application error callback on fire - Panda::CONFIG_ENABLE_FIREPHP => true, // enable firephp on firefox ? - Panda::CONFIG_CATCH_FATAL => true, // catch fatal error ? (recommend false for debug) - Panda::CONFIG_PANDA_PATH => '/', // Panda htdocs base path - Panda::CONFIG_EDITOR => Panda::EDITOR_BESPIN | Panda::EDITOR_TEXTMATE, // Text editor link +Panda::init([ + Panda::CONFIG_DEBUG => true, // debug mode + Panda::CONFIG_VALID_PATH => array('/'), // valid path (user source code path) + Panda::CONFIG_LOG_PATH => '/tmp/', // log directory path + Panda::CONFIG_HTTP_TPL => dirname(__DIR__) . '/Panda/templates/http.php', // custom Http error output template + Panda::CONFIG_FATAL_HTML => dirname(__DIR__) . '/Panda/templates/fatal.php', // fatal error template + Panda::CONFIG_CATCH_FATAL => true, // catch fatal error ? (recommend false for debug) + Panda::CONFIG_PANDA_PATH => '/', // Panda htdocs base path + Panda::CONFIG_EDITOR => Panda::EDITOR_BESPIN | Panda::EDITOR_TEXTMATE, // Text editor link Panda::CONFIG_CATCH_STRICT => true -); // catch stric error in compile ? -Panda::init($config); - -/** - * Application error handler - * - * @param string $headering - * @param string $subheading - * @param array $info - * @param array $options - * - * @return void - */ -class Panda_App_Error_Handler -{ - public static function onError($heading, $subheading, $info, $options) - { - } -} \ No newline at end of file +]); diff --git a/data/htdocs/panda_sample/pear_error.php b/data/htdocs/panda_sample/pear_error.php index 2bbc18f..82d4c50 100644 --- a/data/htdocs/panda_sample/pear_error.php +++ b/data/htdocs/panda_sample/pear_error.php @@ -1,8 +1,4 @@ From 178a5ca7391ef4280146e7a74b354563d5946c75 Mon Sep 17 00:00:00 2001 From: Akihito Koriyama Date: Tue, 22 Jan 2019 16:12:26 +0900 Subject: [PATCH 17/21] demo code move to /example --- {data/htdocs/panda_sample => example}/__panda | 0 {data/htdocs/panda_sample => example}/default.css | 0 {data/htdocs/panda_sample => example}/fatal_error.php | 0 {data/htdocs/panda_sample => example}/index.php | 0 {data/htdocs/panda_sample => example}/index.view.php | 0 {data/htdocs/panda_sample => example}/memory_error.php | 0 {data/htdocs/panda_sample => example}/panda_exception.php | 0 {data/htdocs/panda_sample => example}/panda_ini.php | 0 {data/htdocs/panda_sample => example}/pear_error.php | 0 {data/htdocs/panda_sample => example}/uncaught_exception.php | 0 {data/htdocs/panda_sample => example}/utility.php | 0 11 files changed, 0 insertions(+), 0 deletions(-) rename {data/htdocs/panda_sample => example}/__panda (100%) rename {data/htdocs/panda_sample => example}/default.css (100%) rename {data/htdocs/panda_sample => example}/fatal_error.php (100%) rename {data/htdocs/panda_sample => example}/index.php (100%) rename {data/htdocs/panda_sample => example}/index.view.php (100%) rename {data/htdocs/panda_sample => example}/memory_error.php (100%) rename {data/htdocs/panda_sample => example}/panda_exception.php (100%) rename {data/htdocs/panda_sample => example}/panda_ini.php (100%) rename {data/htdocs/panda_sample => example}/pear_error.php (100%) rename {data/htdocs/panda_sample => example}/uncaught_exception.php (100%) rename {data/htdocs/panda_sample => example}/utility.php (100%) diff --git a/data/htdocs/panda_sample/__panda b/example/__panda similarity index 100% rename from data/htdocs/panda_sample/__panda rename to example/__panda diff --git a/data/htdocs/panda_sample/default.css b/example/default.css similarity index 100% rename from data/htdocs/panda_sample/default.css rename to example/default.css diff --git a/data/htdocs/panda_sample/fatal_error.php b/example/fatal_error.php similarity index 100% rename from data/htdocs/panda_sample/fatal_error.php rename to example/fatal_error.php diff --git a/data/htdocs/panda_sample/index.php b/example/index.php similarity index 100% rename from data/htdocs/panda_sample/index.php rename to example/index.php diff --git a/data/htdocs/panda_sample/index.view.php b/example/index.view.php similarity index 100% rename from data/htdocs/panda_sample/index.view.php rename to example/index.view.php diff --git a/data/htdocs/panda_sample/memory_error.php b/example/memory_error.php similarity index 100% rename from data/htdocs/panda_sample/memory_error.php rename to example/memory_error.php diff --git a/data/htdocs/panda_sample/panda_exception.php b/example/panda_exception.php similarity index 100% rename from data/htdocs/panda_sample/panda_exception.php rename to example/panda_exception.php diff --git a/data/htdocs/panda_sample/panda_ini.php b/example/panda_ini.php similarity index 100% rename from data/htdocs/panda_sample/panda_ini.php rename to example/panda_ini.php diff --git a/data/htdocs/panda_sample/pear_error.php b/example/pear_error.php similarity index 100% rename from data/htdocs/panda_sample/pear_error.php rename to example/pear_error.php diff --git a/data/htdocs/panda_sample/uncaught_exception.php b/example/uncaught_exception.php similarity index 100% rename from data/htdocs/panda_sample/uncaught_exception.php rename to example/uncaught_exception.php diff --git a/data/htdocs/panda_sample/utility.php b/example/utility.php similarity index 100% rename from data/htdocs/panda_sample/utility.php rename to example/utility.php From 75779d9f564ed81131e9e5303f5db2842ec53135 Mon Sep 17 00:00:00 2001 From: Akihito Koriyama Date: Tue, 22 Jan 2019 16:16:01 +0900 Subject: [PATCH 18/21] fix demo --- example/index.php | 5 +++-- example/pear_error.php | 2 ++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/example/index.php b/example/index.php index e4cbd44..2814b85 100644 --- a/example/index.php +++ b/example/index.php @@ -1,7 +1,8 @@ Date: Tue, 22 Jan 2019 16:16:29 +0900 Subject: [PATCH 19/21] fix http template exists check --- Panda.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Panda.php b/Panda.php index 432d58e..683002f 100644 --- a/Panda.php +++ b/Panda.php @@ -1146,10 +1146,11 @@ public static function outputHttpStatus($code, $withBody = true, $body = '', $id 'body' => $body, 'serverProtocol' => $serverProtocol, 'id' => $id); - $include = include self::$_config[self::CONFIG_HTTP_TPL]; - if (!$include) { + $tpl = self::$_config[self::CONFIG_HTTP_TPL]; + if (! file_exists($tpl)) { trigger_error('CONFIG_HTTP_TPL file [' . self::$_config[self::CONFIG_HTTP_TPL] . '] is not exist.'); } + include $tpl; } } From 47cb5f31e81eac231ce90db4308dc74d3a9905cc Mon Sep 17 00:00:00 2001 From: Akihito Koriyama Date: Tue, 22 Jan 2019 16:30:38 +0900 Subject: [PATCH 20/21] do not redefine p() function --- Panda.php | 3 --- Panda/Debug/util.php | 4 ++++ tests/Test/Panda/PandaTest.php | 19 +++++++++++-------- 3 files changed, 15 insertions(+), 11 deletions(-) diff --git a/Panda.php b/Panda.php index 683002f..91752f0 100644 --- a/Panda.php +++ b/Panda.php @@ -331,9 +331,6 @@ public static function init(array $config = array()) // reset handler if (self::$_config[self::CONFIG_DEBUG] !== true) { ini_set('display_errors', 0); - function p($v = ''){ - syslog(LOG_INFO, print_r($v, true)); - } if (class_exists('PEAR', false)) { PEAR::setErrorHandling(PEAR_ERROR_CALLBACK, array('Panda', 'onPearError')); } diff --git a/Panda/Debug/util.php b/Panda/Debug/util.php index 06b1cbe..52aabdf 100644 --- a/Panda/Debug/util.php +++ b/Panda/Debug/util.php @@ -54,6 +54,10 @@ */ function p($mixed = null, $format = 'dump', array $options = array()) { + $config = Panda::getConfig(); + if (! isset($config[Panda::CONFIG_DEBUG]) || $config[Panda::CONFIG_DEBUG] === false) { + return; + } if (PHP_SAPI === 'cli') { call_user_func('v', func_get_args()); return; diff --git a/tests/Test/Panda/PandaTest.php b/tests/Test/Panda/PandaTest.php index 43f7206..949b695 100644 --- a/tests/Test/Panda/PandaTest.php +++ b/tests/Test/Panda/PandaTest.php @@ -4,21 +4,18 @@ class PandaTest extends PHPUnit_Framework_TestCase { protected function setUp() { - $config = [ + Panda::init([ Panda::CONFIG_DEBUG => false, Panda::CONFIG_VALID_PATH => ['/'], Panda::CONFIG_LOG_PATH => '/tmp', - Panda::CONFIG_ON_ERROR_FIRED => false, - Panda::CONFIG_ON_FATAL_ERROR => 'Panda/template/fatal.html', - Panda::CONFIG_ENABLE_FIREPHP => true, - Panda::CONFIG_FATAL_HTML => 'Panda/template/fatal.html', - Panda::CONFIG_HTTP_TPL => 'Panda/template/http.php', + Panda::CONFIG_ON_FATAL_ERROR => dirname(__DIR__, 2) .'/Panda/template/fatal.html', + Panda::CONFIG_FATAL_HTML => dirname(__DIR__, 2) . '/Panda/template/fatal.html', + Panda::CONFIG_HTTP_TPL => dirname(__DIR__, 2) . '/Panda/template/http.php', Panda::CONFIG_CATCH_FATAL => false, Panda::CONFIG_CATCH_STRICT => true, Panda::CONFIG_PANDA_PATH => '/', Panda::CONFIG_EDITOR => 0 - ]; - Panda::init($config); + ]); } public function testGetConfig() @@ -27,4 +24,10 @@ public function testGetConfig() $this->assertTrue(isset($config[Panda::CONFIG_DEBUG])); $this->assertFalse($config[Panda::CONFIG_DEBUG]); } + + public function testP() + { + $result = p('debug'); + $this->assertNull($result); + } } From 45e423c840cb8cd3e655ff80adcb7e4d43d09fc2 Mon Sep 17 00:00:00 2001 From: Akihito Koriyama Date: Tue, 22 Jan 2019 16:30:53 +0900 Subject: [PATCH 21/21] Update README.md --- README.md | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 09dd4db..6482202 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,13 @@ Panda is a PHP error handler for [BEAR.Saturday](https://github.com/bearsaturday/BEAR.Saturday) framework -# Requirement +# Testing + + * vendor/bin/phpunit + +# Run Demo + + * php -S 127.0.0.1:8080 -t example + + See http://127.0.0.1:8080/ - * PHP ^5.4 - * PHP ^7.0