Last active
April 23, 2026 08:32
-
-
Save AnrDaemon/57d92d9297f87b2e27c77af652e83276 to your computer and use it in GitHub Desktop.
TWIG debug breakpoint
This file contains hidden or 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 | |
| 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