Xdebug on Laravel Octane with Swoole Running

Kidd Tang
Dev Genius
Published in
3 min readJul 9, 2021

--

Swoole opens a brand new world for PHP developers, while conventional tools (like Xdebug) do not support Swoole due to the architectural differences.

On the Swoole documentation, the YASD (Yet Another Swoole Debugger) is developed as the replacement of Xdebug. Till the time of writing, it is still the alpha and experimental stage.

Here is the trick to keep Laravel Octane running on Swoole while Xdebug can be used without disruption.

I will skip the fundamental steps, you can always refer to:

  1. Kickstart your Laravel Web App using Laravel Sail (WSL2)
  2. Laravel Sail with HTTPS Swoole
  3. Xdebug Laravel Sail project in VS Code

If you follow my tutorial for setting up HTTPS Swoole, you should have published and edit the docker/8.0/supervisord.conf file. Now, I make both PHP built-in server and Swoole running at the same time.

HTTPS — Port 8080 — For Swoole
HTTP — Port 80 — For Xdebug

This is the sample of the supervisord.conf

Make sure the instances named differently

Remider: Your docker-compose.yml needs to expose the Port properly too.

Once you finish the editing and follow the guide in Xdebug Laravel Sail project in VS Code, you need to sail down and rebuild your docker image

sail build --no-cache

Then

sail up

You should be able to run on both http://localhost & https://localhost:8000

Make sure you install Xdebug helper extension (Chrome)

Then Enable it when you want to debug on http://localhost

The Laravel Octane will be still accessible without disruption. If you encounter any issues, please feel free to leave comments below!

Video Demo:

Are you ready to put your sites online with unlimited app hosting for only $14 per month?

Cloudways comes with tons of features that make you easily host your Laravel, WordPress, or any PHP sites without worrying about cyber-securities nightmares.

Now you can extra discount during the BFCM 2023 campaign period!

Link: www.cloudways.com/en/?id=66136

Let’s start trying the Cloudways!

--

--