Create a mapping from server side directories to PHPStorm-side code (A "Server" configuration in PHPStorm).This can be done via source control with matching code, by mounting the remote directory to your local machine, or any way you want. We'll create a PHPStorm project that contains all the code we want to debug on the remote machine.Just enter PHPStorm's Run/Debug configuration and create a new "PHP Script" configuration. Note: If you just want to debug a PHP script (or drush command) on the local machine, that's much easier. You just have to set up a couple of environment variables, map the remote code to the local code that PHPStorm has at its disposal, and tunnel the xdebug connection to your workstation. php files.XDebug with PHPStorm can do step-debugging on remote sessions started from the command line on a remote machine. This process fails miserably if the Symfony part in the Nginx configuration file is wrapped in a location directive which only maps index.php instead of mapping all. PhpStorm, to validate the configuration, creates a PHP file at Path to create validation script and then “visits” it using Url to validation script as URL prefix. localhost is the port on which our web server is published).Ĭlick on the Validate button below, and hopefully something similar should happen. Path to create validation script points to the directory where the document root is mapped: in a Symfony (>=3) project, this directory is not the project directory, but the public/ subdirectory. In the window that opens, please make sure that: In the Settings window, select Languages & Frameworks > PHP > Debug and click on the Validate link. Press OK again and select the newly created interpreter under CLI Interpeter. Input the values below:īy clicking OK in this window, the previous one should show the following. In the window that opens, press the + button to configure the container CLI interpreter and select From Docker, Vagrant, VM, WSL, Remote …. In the Settings window, select the Languages & Frameworks > PHP item and click on the button with the three dots next to CLI Interpreter to define the PHP interpreter to use. PHP_IDE_CONFIG=serverName=symfony-docker in docker-compose.yml in the highlighted line ( symfony-docker in this example): The name we give to the server in PhpStorm must match the one set as serverName in the environment variable PHP_IDE_CONFIG, i.e. the path where we mounted the sources in docker-compose.yml. On that line, on the right column, enter the corresponding path of the php container, i.e. Then, check Use path mappings, and in the panel below, in the left column, find the directory that contains the PHP project sources. In the Settings window, select the Languages & Frameworks > PHP > Servers and click on the + button to configure the PHP server to use: specify localhost as host and 8080 as the port (the same port we’re forwarding in docker-compose.yml). In PhpStorm, Let’s open the Settings window ( Ctrl - Alt - S ), select Build, Execution, Deployment > Docker, then press the + button to configure integration with Docker. On the Docker side, we’re done: we now must make our container and PhpStorm talk to each other. The Dockerfile is shown below:ĬOPY entrypoint.sh /usr/local/bin/entrypoint.sh RUN chmod 755 /usr/local/bin/entrypoint.sh ENTRYPOINT Setting up debugging in PhpStorm To be able to compile the extensions at build time, and to always have some useful commands at hand (in the container), I install some packages with apt-get. These extensions are installed with the docker-php-ext-install command for debugging I need the xdebug extension, which is a PECL extension and must be installed using the pecl install command. a database ( postgresql), not relevant for the purpose of this post.įor this project I start from the Docker image php: 7.4-fpm-buster (Debian 10), and in the Dockerfile I install the PHP extensions needed for Symfony:.a webserver ( Nginx in my case, but this post applies almost unchanged to Apache).Development environmentįor a Symfony 5 application I’m developing, I’m using a docker-compose development environment made of three containers: This post is an attempt to troubleshoot all -or most- of these issues. If you are developing in PHP on Linux, using a Docker development environment, you may face issues unknown to Mac and Windows guys □. How to make PhpStorm’s debugger behave using Docker on Linux.
0 Comments
Leave a Reply. |