Ritu Singh
To make Xdebug stop at breakpoints in PhpStorm when using Docker, you need to ensure that Xdebug is correctly configured in your PHP container and PhpStorm is configured to listen for incoming Xdebug connections.
Here's a step-by-step guide:
Configure Xdebug in Your PHP Container:
Add or modify the Xdebug configuration in your php.ini or a separate .ini file:
Ensure that zend_extension points to the correct location of the Xdebug extension in your container.
Set xdebug.remote_enable to 1 to enable Xdebug.
xdebug.remote_autostart=1 automatically starts a debugging session for every request.
xdebug.remote_connect_back=0 ensures that Xdebug connects back to the specified host.
xdebug.remote_host should be set to docker.for.mac.localhost for macOS, docker.for.win.localhost for Windows, or the IP address of your host machine.
xdebug.remote_port is the port on which Xdebug communicates with PhpStorm.
2. Configure PhpStorm for Xdebug:
Open PhpStorm and go to Settings/Preferences.
Navigate to Languages & Frameworks > PHP > Debug.
Set the Xdebug port to the same port specified in your xdebug.remote_port configuration (default is 9000).
3. Create a PHP Remote Debug Configuration:
Go to Run > Edit Configurations.
Click on the "+" button to add a new configuration and choose "PHP Remote Debug".
Set the name and IDE key (can be any string, e.g., PHPSTORM).
Click "OK".
4. Set Breakpoints And Run Your Docker Container In Debug Mode:
When starting your Docker container, ensure that it runs PHP in debug mode. You can achieve this by passing the -dxdebug.remote_enable=1 option to the docker run command.
Remember to Replace your-server-name with the server name configured in PhpStorm and adjust other parameters based on your setup.
Credit:> Stack Overflow
Suggested blogs:
>How to create a One Page App with Angular.js, Node.js and MongoDB?
>How to Create an array based on two other arrays in Php
>How To Create Nested Table Structure In Angular?
>How to Create_function deprecated in PHP?
>How to delete duplicate names from Array in Typescript?
>How to do PHP Decryption from Node.js Encryption