Skip to content

Instantly share code, notes, and snippets.

@AnrDaemon
Last active April 23, 2026 08:32
Show Gist options
  • Select an option

  • Save AnrDaemon/57d92d9297f87b2e27c77af652e83276 to your computer and use it in GitHub Desktop.

Select an option

Save AnrDaemon/57d92d9297f87b2e27c77af652e83276 to your computer and use it in GitHub Desktop.
TWIG debug breakpoint
<?php
namespace App\Twig;
use Twig\Extension\AbstractExtension;
use Twig\TwigFunction;
class DebugExtension extends AbstractExtension
{
public function getFunctions(): array
{
return [
new TwigFunction('breakpoint', $this->doBreakpoint(...), ['needs_context' => true, 'needs_environment' => true]),
];
}
/**
* Triggers xDebug breakpoint, if exists.
*/
public function doBreakpoint($env, $context, ...$args)
{
if (function_exists('xdebug_break')) {
\xdebug_break();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment