Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Prpdl's avatar
Level 2

Debugging in Laravel Octane

Why can't I get Laravel Octane to bootstrap my application on every single request when I'm trying to debug? And to add to my frustrations, Xdebug seems utterly useless as well! I've been struggling to inspect what's actually being passed in the vendor files during each request. Persistent memory, while great for performance, is a total nightmare for debugging this way. I'm seriously at the end of my rope and could use some guidance!

0 likes
1 reply
LaryAI's avatar
Level 58

Debugging applications running under Laravel Octane can indeed be challenging due to its long-lived application approach. However, there are a few strategies you can employ to make this process easier.

Firstly, it's important to understand that Octane keeps the application bootstrapped between requests to improve performance. This means that changes in your code might not be reflected immediately as they would be in a traditional non-swoole environment.

Here's what you can do to improve your debugging experience with Laravel Octane and Xdebug:

  1. Clear the Octane Cache: Before you start debugging, make sure to clear the Octane cache to ensure that your application is bootstrapped afresh. You can do this by running:
php artisan octane:reload

This command will restart the Octane workers and should be run every time you make changes to your code that you want to be reflected in the running application.

  1. Configure Xdebug Properly: Ensure that Xdebug is configured correctly for CLI-based applications. You might need to set the xdebug.start_with_request to yes in your php.ini or relevant Xdebug configuration file to force Xdebug to start with every request.
xdebug.mode = debug
xdebug.start_with_request = yes
xdebug.client_host = 127.0.0.1
xdebug.client_port = 9003
  1. Use Xdebug's Trigger Feature: If you don't want Xdebug to start with every request, you can use the trigger feature. You can start Xdebug with a trigger like a GET/POST variable or a cookie. For example, you can use the XDEBUG_TRIGGER GET parameter to start debugging.

  2. Log Debugging: If Xdebug is not an option, consider using logging to debug your application. Laravel's logging facilities are very powerful and can be used to log the state of your application at any point.

\Log::debug('Inspecting variable', ['variable' => $variable]);
  1. Tinker: Use Laravel Tinker to run pieces of your code in an isolated environment. This can be helpful to test services and other parts of your application without running the full Octane server.
php artisan tinker
  1. Disable Octane's Cache Temporarily: For debugging purposes, you can temporarily disable Octane's in-memory caching by setting the octane.cache config to false. This will force Octane to bootstrap the application on every request, similar to a traditional Laravel setup.

Remember to revert this change in production or when you're done debugging, as it will significantly impact performance.

  1. Use Octane's Table and Cache Commands: Laravel Octane provides commands to manage the table and cache, which can be useful for debugging:
php artisan octane:cache
php artisan octane:table

These commands can help you inspect and manage the data stored in Octane's tables and cache.

By following these steps, you should be able to debug your Laravel Octane application more effectively. Remember to always check the documentation for the most up-to-date information on debugging with Laravel Octane and Xdebug.

Please or to participate in this conversation.