![]()
0 Comments
![]() PHONY : execute-in-container execute-in-container : # Execute a command in a container. Simply set a break point, right-click on a file and choose "Debug '.'"įor code that is executed "directly" by a container without PhpStorm, we first need to enable xdebug in the container by removing the in front of the extension in /etc/php8/conf.d/zz-app-local.ini Derick is doing a great job at explaining xdebug in detail including some helpful videos like Xdebug 3: Xdebug with Docker and PhpStorm in 5 minutes PhpStorm will now execute tests using the PHP interpreter in the application containerįirst of all, if you haven't already please also take a look at the official xdebug documentation. Then, we add the paths to the composer autoload script and the phpunit.xml configuration file. First, we select the interpreter that we just added Phpunit is configured via File | Settings | PHP | Test Frameworks. The screenshot shows that PhpStorm adds the Xdebug extension that we defined previously. You can find the path in the application container viaĪfterwards we can set a breakpoint e.g. In addition, we define the path to the xdebug extension because it is disabled by default but PhpStorm can enable it automatically if required. docker/.envĪt File | Settings | PHP add a new PHP CLI interpreter that uses the new SSH Configuration Port: see APPLICATION_SSH_HOST_PORT in.Before, we have been using an SFTP Deployment configuration, which was kinda confusing ("What is SFTP doing here?"), so we will use an SSH Configuration instead and configure the path mappings in the Cli Interpreter interfaceĪt File | Settings | Tools | SSH Configurations create a new SSH Configuration named "Docker PHP Tutorial" with the following settings We will configure a remote PHP interpreter that uses an SSH connection to run commands in the application container. In addition, composer needs the extensions mbstring and pharĮnter fullscreen mode Exit fullscreen mode Install composer Composer is installed by pulling the official composer docker image and simply "copying" the composer executable over to the base php image. ![]() This reduces complexity and removes any pesky warnings regarding "SSH keys being exposed in a repository". However, we will not use SSH keys any longer but simply authenticate via password. ![]() We will still rely on an always-running docker setup that we connect to via an SSH Configuration instead of using the built-in docker-compose capabilities as I feel it's closer to what we do in CI / production. This article is mostly an update of Setting up PhpStorm with Xdebug for local development on Docker but will also cover the "remaining cases" of debugging php-fpm and php worker processes. If you want to follow along, please subscribe to the RSS feed or via email to get automatic notifications when the next part comes out :)ĭebug code executed via php-fpm, cli or from a worker The previous part was Docker from scratch for PHP 8.1 Applications in 2022 and the following one is Run Laravel 9 on Docker in 2022. You find the branch for this tutorial at part-4-2-phpstorm-docker-xdebug-3-php-8-1-in-2022Īll published parts of the Docker PHP Tutorial are collected under a dedicated page at Docker PHP Tutorial. We will also ensure that we can run PHPUnit tests from the command line as well as from PhpStorm and throw the tool strace into the mix for debugging long running processes.Īll code samples are publicly available in my Docker PHP Tutorial repository on Github. In this part of the tutorial series on developing PHP on Docker we will setup our local development environment to be used by PhpStorm and Xdebug. This article appeared first on at PhpStorm, Docker and Xdebug 3 on PHP 8.1 in 2022 |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |