It's set to 0 because we are going to use the static IP address of the host IP running Docker. #If enabled, this setting will activate the discovery of the client's IP address. In version 3, you can specify multiple modes separated by comma Then ensure that PhpStorm is listening for debug connections.#setting xdebug working mode. Go to File > Settings > Languages & Frameworks > PHP > Debug and ensure PhpStorm is listening for Xdebug on port 9000 and can accept external connections. Now you should be able to run your PHPUnit tests within PhpStorm without doing a docker exec into your service container.įollow these steps to get PHPStorm to listen for XDebug on the right port In the dialog that comes up, select the CLI interpreter we created in the previous step from the drop-down. Go to File > Settings > Languages & Frameworks > PHP > Test Frameworks and add a new PHPUnit by Remote Interpreter configuration. If you select the Always start a new container option, then each time your run PHPUnit within PhpStorm, a new container that is not joined to any of your networks will be created.įollow these steps to configure PHPUnit in PHPStorm This is important if you're working with a separate container for your database and it ensures that PhpStorm has access to the network your containers are joined to. For me, that's the web service.Įnsure to select the Connect to existing container option. 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.
0 Comments
Leave a Reply.AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |