AuthorColleen ArchivesCategories |
Back to Blog
Phpstorm Docker For Mac10/13/2021
You can spin up the services with docker-compose up in the terminal manually, and then use PhpStorm in the exec mode (the option is visible on your screenshot).Docker for Mac, Docker for Windows or Docker (Linux) 1.13+. Docker Compose itself doesnt map ports in this case, you can check it in the terminal. PhpStorm does docker-compose run servicename command. Docker-compose up is not equivalent to docker-compose run. That means, with the PHPStorm docker integration, you can use a docker image to run your tests, however you cannot connect to an existing, running docker container and use that to run your scripts.While this way still works, I have found a better way - see my new blog post about it.NET Web API (Brian Lagunas) WebStorm 2021.3 Early Access Program Is Now Open (Ekaterina Ryabukha) What is ViewData and implement ViewData in ASP.NET MVCBest answer. PHPStorm has a pretty good docker integration if we are talking about docker run or docker-compose run.Long story short: There is a bug in the networking setup of Docker for Win that makes PhpStorm use the wrong remotehost when it starts a debugging session. Basically, what I wanted to achieve is what you see on the screenshot:Fix Xdebug on PhpStorm when run from a Docker container. PhpStorm.As I am using DDEV for most of my projects as simple docker environment for web development and PHPStorm as IDE I wanted to be able to run test from PHPStorm - not only as a script, but fully integrated with coverage and test debugging.
PHPStorm also offers the option to add a remote interpreter over SSH. With DDEV, that is what we would need: We have DDEV running and now want PHPStorm to execute our tests in the DDEV environment.While we cannot use PHPStorms docker integration, what we can use is the SSH integration. That means, with the PHPStorm docker integration, you can use a docker image to run your tests, however you cannot connect to an existing, running docker container and use that to run your scripts. NOTE: The actual debug.so extention is NOT SET HERE but rather (/usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini).PHPStorm has a pretty good docker integration if we are talking about docker run or docker-compose run. Laradock/php-fpm/xdebug.ini. Elgato video capture capture analog video for your mac or pc iAllow authentication with our private key Make the SSH server accessible from the host Install an SSH server on our DDEV web container ![]() ![]() Add PHPUnit by Remote InterpreterAs a last step to get our PHPUnit tests running via SSH we need to add a PHPUnit configuration - in PHPStorm: Choose SSH and configure the SSH connectionWith this config it's already possible to run all PHP script related things in PHPStorm in the DDEV environment. Click the + sign and choose the From Docker, Vagrant, Vm, WSL, Remote option Go to Settings > Languages & Frameworks > PHP Try it: ssh -p 9922 Add PHP over SSH as Remote Interpreter in PHPStormNow that our SSH server is running, we need to configure our PHPStorm to run PHP via SSH. Load phpunit via composer autoloader - the file dialog should already display the remote file systemAll done, you are ready to run tests directly in PHPStorm. Set up path mappings to allow PHPStorm to find the files Choose the SSH PHP interpreter we created in the previous step as CLI Interpreter The configuration is similar to the PHPUnit configuration: With the setup we have now, it's easy to also run these scripts via our ddev interpreter. Bonus: Run composer scripts via ddevIn some projects we are making heavy use of composer scripts as shortcuts for running tests, cgl fixer, PHPStan etc. Open a test file and run the file or a single test by clicking the green arrow iconIf you want to debug tests or run the tests with coverage, you need to enable xdebug first: ddev xdebug onAfter that, you can use the bug icon in PHPStorm to run the tests with a debugger available. Right click a phpunit.xml config file and choose Run If everything is set up correctly you can for example: ![]()
0 Comments
Read More
Leave a Reply. |