Created
April 14, 2014 16:49
-
-
Save uzulla/10664661 to your computer and use it in GitHub Desktop.
Psysh をなんかこうグローバルで良い感じに…うーん、良い感じの書き方がおもいつかないでござる。
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// config | |
define("DEBUG", true); | |
// loading | |
if(DEBUG) | |
include('/path/to/psysh'); | |
// setup | |
set_error_handler(function($errno, $errstr, $errfile, $errline){ | |
throw new ErrorException($errstr, $errno, 0, $errfile, $errline); | |
}); | |
// use | |
try{ | |
echo "Okay, I'll try read the file!"; | |
$filename = "not exists file name here."; | |
file_get_contents($filename); | |
}catch(\Exception $e){ | |
if(class_exists("Psy\\Shell")){\Psy\Shell::debug(get_defined_vars());} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ php index.php | |
Okay, I'll try read the file! | |
Psy Shell v0.1.8 (PHP 5.5.9 — cli) by Justin Hileman | |
>>> ls | |
Variables: $_COOKIE, $_ENV, $_FILES, $_GET, $_POST, $_REQUEST, $_SERVER, $argc, $argv, $e, $filename | |
>>> ls $e | |
Class Properties: $xdebug_message | |
Class Methods: __construct, __toString, getCode, getFile, getLine, getMessage, getPrevious, getSeverity, getTrace, getTraceAsString | |
>>> $e->getMessage() | |
ErrorException with message 'Undefined variable: undefinedVariable' | |
>>> $e->getFile(); | |
=> "/tmp/PsyshTest/index.php" | |
>>> $e->getLine(); | |
=> 18 | |
>>> echo $filename | |
not exists file name here.⏎ | |
=> null | |
>>> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment