![]() When running ‘Debug’ I would see the debug console “ Connection with Waiting for incoming connection with ide key” and then once the test finished, I would get an event error “ Connection with 'Xdebug 2.2.5' was not established”.Īfter digging through each of the xdebug configuration options and trying all sorts of combinations I finally figured out it was an issue with how PHPStorm was sending the PHPUnit request to the CLI docker://docker/php5:latest/php \ Watch that tutorial (props to as I found with most of these tutorials, they are mostly geared for web based applications, my app doesn’t have a web interface only CLI which is tested using PHPUnit. Getting set up with docker to run all my PHPUnit tests was a breeze and actually saved me a load of time (previously I would run it from the terminal (running a docker container and going back-n-forth didn’t help with the RSI in my wrists). The Advanced Settings and “ Pass required configuration options through command line” should be disabled and you should provide your own configuration options to your Docker CLI interpreter. It basically came down to the remote host (provided automatically by PHPStorm and the ‘zero config’) not working with the debugger. A breakpoint can be set in the app or tests can be run with coverage :)Įdit: Added details on running commands on MacOS and Windows and small tweaks.Although PHPStorm has done a great job with the zero configuration debugging for web server applications, it’s not quite that easy (for me any way) for CLI applications, particularly when using Docker for Mac as the CLI Interpreter. Thanks to this setup, xDebug has been automatically configured! It will use the default PHP Interpreter, which wasĬonfigured in step 2. Run the tests What about configuring xDebug? # Under Test Runner choose Defined in the configuration file.Click Edit Configuration (next to run test button).Under Test runner, tick Default configuration script, type in the path, in the docker container. ![]() Input the script path based on the mapping inside the container e.g.Confirm the path mappings, as above →/app.Choose the interpreter created above, e.g.Choose the Service from the drop down list (e.g.Click the ellipse button next to CLI Interpreter., the setup process can be easily replicated.ĭocker settings 2. Video Running PHPUnit Tests in PhpStorm with Docker Thanks to Gary Hockin’s excellent YouTube Now the project has been cloned from GitHub and the dependencies have been installed. You can work around this by running the container with a different user:ĭrwxr-xr-x 27 michael michael 4096 Sep 30 21:36 vendorĪbout running Docker containers as current host userĪnd docker-compose cli reference. This can lead to permission issues on your host filesystem. This is the script recommended on the docker hub composer page to avoid filesystemīy default, Composer runs as root inside the container. ![]() To keep things simple the composer Docker container can be used to install the dependencies. data:/var/lib/mysql Install dependencies using composer # #XDEBUG_CONFIG: remote_host=, remote_port=9001 working_dir : "/var/www/html" mysql : image : phpstorm/mysql ports : - "33056:3306" volumes :. ![]() If this is # the case, in the Settings | Languages & Frameworks | PHP | Debug, set the # Debug port to 9001, and use the following configuration line instead. PhpStorm will # remain silent on starting listening for incoming connections. XDEBUG_CONFIG : remote_host=pop-os #For macOS, if you use a local Homebrew php-fpm installation, port `9000` # (which is the default debugging port) may become occupied. #For Linux, replace the line below with your hostname, # which you can obtain by executing `hostname` in Terminal. :/var/# which will automatically resolve to the internal address of the host # Docker is running on. Version : '2' services : debug : image : phpstorm/php-73-apache-xdebug-27 ports : - "8081:80" volumes :.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |