sajad torkamani

Ensure you’ve installed XDebug and then add a file at src/EventSubscriber/ApiExceptionListener.php:



namespace App\EventSubscriber;

use Symfony\Component\EventDispatcher\Attribute\AsEventListener;
use Symfony\Component\HttpKernel\Event\ExceptionEvent;
use Symfony\Component\HttpKernel\KernelEvents;

#[AsEventListener(event: KernelEvents::EXCEPTION, method: 'onKernelException')]
final readonly class ApiExceptionListener
    public function onKernelException(ExceptionEvent $event): void
        $exception = $event->getThrowable();
        $foo       = 'bar'; // Any line will do. This is just so that we can set the breakpoint here

Set the breakpoint here:

API Platform: How to add XDebug breakpoint on 500 error