Configure the Local Beach PHP interpreter for PhpStorm
See also: Jetbrains Documentation
- Go to Settings/Preferences (⌘,), then go to Languages & Frameworks | PHP
- On the PHP page click […] next to the CLI Interpreter list
- In the CLI Interpreters dialog, click [+] in the left-hand pane, then choose From Docker... from the popup menu
- In the Configure Remote PHP Interpreter dialog choose Docker
- Provide the PHP interpreter connection parameters
- As Server choose "Docker"
- As Image name use flownative/beach-php:7.4 (or the respective PHP version you use in your project)
- Check that the PHP executable / PHP version is detected correctly (might take a while, if PhpStorm needs to download the Docker image first). There's a small [i] icon above the "Debugger: Xdebug" label which allows you to display some phpinfo() output. If the [i] icon is disabled, click on the reload icon (next to it) first
- open the Docker container mapping dialog and adjust the container path to /application. You may also want to raise the PHP memory limit by adding the environment variable PHP_MEMORY_LIMIT with the desired value
- choose the PHP Runtime tab and click on Sync Extensions with Interpreter
Configure PHPUnit
- Go to Languages & Frameworks > PHP > Test Frameworks
- Add PHPUnit by Remote Interpreter and choose the Docker-based interpreter you configured previously
- Configure the PHPUnit remote interpreter like in the following screenshots. Especially make sure to point to the correct default configuration file and default bootstrap file
- If you like, adjust the color scheme for line coverage annotations:
- Test your setup by running a unit test case. In order to do that, right-click on a test case file and select "Run 'YourTestCaseName' (PHPUnit)"
- See the test results: