Select the docker-compose service that contains your PHP installation. Click the Add a new CLI interpreter from Docker, vagrant. Go to File > Settings > Languages & Frameworks > PHP to configure PHP's CLI. Select the Use path mappings option since we are working with docker containers and map your project root on your host to your project root in the docker container.įollow these steps to configure PhpStorm's PHP CLI interpreter ![]() In my case I am publishing my web service's port 80 to my host container's port 8080 so I'd be filling in 8080 for port. Add a new server and set the host to localhost and the port to whatever port you are publishing your docker-compose web service to. But you can leave the defaults.Ĭonfigure PHPStorm's local server to point to your docker service by going to File > Settings > Languages & Frameworks > PHP > Servers. I usually change the name of my configuration to something more memorable and I like to check the force builds option. I observed that it takes a while to show up.Ī configuration box will pop up where you can modify some options. If you don't see this create option, wait a bit and right click again. Right click on your docker-compose.yml file and select "Create docker-compose.yml." So putting everything together my PHP project in PhpStorm currently looks like this (it's a new Laravel project I scaffolded for this tutorial).įollow these steps to create a new PhpStorm Run/Debug configuration. In the docker-compose file I'm using for this tutorial I have 3 services (2 database services and one web service) as you can see in this snippet:Įnter fullscreen mode Exit fullscreen mode You can get access to the original files from his Freecodecamp PHP OOP course Github repository. The docker-compose.yml and Dockerfile configuration files I'm using for this article were created by Peter Fisher of How to Code Well and slightly modified by me. Part 1: Configurations for docker-compose.yml, Dockerfile and Xdebug Please be aware that some of the configuration options I am about to discuss are not available in certain older versions of PhpStorm. Note: The information in this article should work well with PhpStorm version 2019.2 and up. Running our test-suite with PhpStorm and PHPUnit (with PHP installed in a docker-compose service container).Debugging our code with PhpStorm and Xdebug (with Xdebug installed in a docker-compose service container).Setting up the PhpStorm IDE so we can start and stop our docker-compose containers from within the IDE.In this article we'll go through the following: ![]() I am hoping this resource can be a good reference for myself and for others who might run into the same issues that I ran into. ![]() I decided to write this article because I was frustrated by how difficult it was to find all the information I needed to make these technologies work well together in a single article. Setup PHPStorm to run PHPUnit tests within docker container
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |