Skip to content

Instantly share code, notes, and snippets.

@docteurklein
Created November 9, 2011 18:28
Show Gist options
  • Save docteurklein/1352375 to your computer and use it in GitHub Desktop.
Save docteurklein/1352375 to your computer and use it in GitHub Desktop.
<?php
use Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent;
/**
* a vim exception handler
*
* Commands a remote vim instance to display the stacktrace in a quickfix list
*
* @author Florian Klein <[email protected]>
*/
class VimExceptionHandler
{
public function onKernelException(GetResponseForExceptionEvent $event)
{
$exception = $event->getException();
$stack = '';
foreach ($exception->getTrace() as $row) {
if (isset($row['file'])) {
$stack .= sprintf('%s | %s | %s', $row['file'], $row['line'], $row['function'])."\n";
}
}
file_put_contents('/tmp/stack.php', $stack);
$cmd = sprintf('vim --servername %s --remote-send ":call PhpStackTrace()<CR>"', 'florian');
shell_exec($cmd);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment