mirror of
https://github.com/filp/whoops.git
synced 2026-08-19 00:50:01 +00:00
1.7 KiB
1.7 KiB
Open Files In An Editor
When using the pretty error page feature, whoops comes with the ability to open referenced files directly in your IDE or editor. This feature only works in case your php-source files are locally accessible to the machine on which the editor is installed.
<?php
use Whoops\Handler\PrettyPageHandler;
$handler = new PrettyPageHandler;
$handler->setEditor('sublime');
The following editors are currently supported by default.
sublime- Sublime Text 2 and possibly 3 (on OS X you might need a special handler)emacs- Emacstextmate- Textmatemacvim- MacVimxdebug- xdebug (uses xdebug.file_link_format)phpstorm- PhpStorm
Adding your own editor is simple:
$handler->setEditor(function($file, $line) {
return "whatever://open?file=$file&line=$line";
});
You can add IntelliJ Platform support like this:
$handler->setEditor(
function ($file, $line) {
// if your development server is not local it's good to map remote files to local
$translations = array('^' . __DIR__ => '~/Development/PhpStormOpener'); // change to your path
foreach ($translations as $from => $to) {
$file = preg_replace('#' . $from . '#', $to, $file, 1);
}
// Intellig platform requires that you send an Ajax request, else the browser will quit the page
return array(
'url' => "http://localhost:63342/api/file/?file=$file&line=$line",
'ajax' => true
);
}
);