The goal of this tutorial is to get the Xdebug working on your server and then point PhpStorm to Xdebug. It collapses from time to time so I have to redo this setup, and therefore I know this setup works :). The app I am working on runs inside of a Vagrant box which is shaky somehow. Since there aren’t many tutorials on how to do it, I’ve encountered some problems on how to get the setup up and running.īy combining a few tutorials and spending a few hours on several forums, I came up with this text. Graduate of EPITECH, Alexis is specialized in PHP frameworks (Symfony, Laravel, Mouf) and he masters Docker.Recently I started focusing more on PHP, and I needed to set up a local debugging environment. About the authorĪlexis is an experienced technical project manager who manages several projects including Eco-Emballages (CITEO). By default, it's /opt/project in the container, just change it to /var/www/htmlĭone! Just click on the Docker button on the bottom of PHPStorm window. (9) You need to set the path mapping for your code. (7) Make sure the connection is successful (3) Click on Docker (remember that you should start Docker daemon) (2) Add a new CLI interpreter by clicking on From Docker, Vagrant, VM, Remote. Now everything should be good, just go to Preferences. Move to your favorite Docker project in PHPStorm.You should check that the "Docker integration" is enabled on your IDE.There is a very useful PHPStorm extension to quickly and efficiently manage your docker containers. ![]() Addentum: Installing Docker integration in PHPStorm Now, just go into your php-apache container using docker exec -ti bash and run your script manually. Place a breakpoint in your code and launch a debug sessionĪ new windows should open and you should access to PHPStorm debug bar.Ĭlick on Start Listening for PHP Debug connections Otherwise, add your custom Xdebug port Run Xdebug Web (4) If you are using the default Xdebug port, please remove remote_port=. (2) If you are using a different Xdebug port, set your custom Xdebug port ini configurations into the docker-compose.yml.įor more details, please look at this TheCodingMachine Docker PHP images. That's why we can set PHP extensions, PHP. Remember that we are using our technical director's (David Négrier) images. In the docker-compose.yml, just add those environment variables Let's see how to enable Xdebug for scripts (CLI) ![]() You might also want to debug a command-line application, from within your container. Xdebug CLIĪll applications are not web-based. Jump to chapter "Run Xdebug" to see how to use Xdebug. Indeed, from the point of view of Xdebug, the PHP application runs in the "/var/this point, you should be able to put a breakpoint in your code, start a debugging session and get the application to stop on the breakpoint. (8) Don't forget to click on Use path mappings (7) Add your host on port 80 using Xdebug (5) Once it's done, you are on debug server page. (2) Confirm it by clicking on PHP Web Page Registering your container server in PHPStormįirst, click on edit configurations, on the top right of PHPStorm window. Otherwise, just keep the default configuration port. If you want to use another port for Xdebug, follow the instructions below. This directly conflicts with the XDebug port. In particular, if you are using PHP-FPM, the default port for PHP-FPM is 9000. except if port 9000 is already taken by another program on your host (your machine running PHPStorm). Out of the box, everything should be fine. Our PHP container has Xdebug installed and Xdebug will try to connect to PHPStorm on port 9000 by default. Keep in mind that PHPStorm opens port 9000 (by default) so Xdebug can connect to it. It automatically configures Xdebug for the container. Note: the PHP_EXTENSION_XDEBUG environment variable is specific to the thecodingmachine/php. Image: thecodingmachine/php:7.2-v1-apache My base docker-compose.yml file looks like this: app: ![]() If you are starting a project, I recommend you to download one of our images here TheCodingMachine Docker PHP images In my example, I will use a Docker image of TheCodingMachine created by David Négrier. To follow this tutorial, you must have the Xdebug extension installed on your container.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |