[1. Download Source](# 1-Download Source) [2.docker settings](# 2-docker settings) [3. phpstorm settings](# 3-phpstorm settings)
git clone https://github.com/symfony/http-kernel.git
cd ./http-kernel
mkdir docker
touch docker/Dockerfile
touch docker/php.ini
touch docker-compose.yml
Dockerfile
FROM php:7.4
RUN pecl install xdebug \
&& docker-php-ext-enable xdebug
RUN apt-get update && \
apt-get upgrade -y && \
apt-get install -y git
php.ini
; timezone
date.timezone = Asia/Tokyo
; error reporing
log_errors = On
error_log = /dev/stderr
; xdebug
xdebug.remote_enable = 1
xdebug.remote_autostart = 1
xdebug.remote_connect_back = 1
docker-compose.yml
version: "3"
services:
php-cli:
build: ./docker
volumes:
- ./:/var/www/html
- ./docker/php.ini:/usr/local/etc/php/php.ini
working_dir: /var/www/html
composer:
image: composer
volumes:
- ./:/app
- ./docker/php.ini:/usr/local/etc/php/php.ini
working_dir: /app
docker-compose run composer install
docker-compose run composer require --dev symfony/phpunit-bridge
By the way, I don't use phpunit / phpunit. [^ 1]
The PHPUnit bridge is designed to work with all maintained versions of Symfony components, even across different major versions of them. You should always use its very latest stable major version to get the most accurate deprecation report.
I get an error when I use it.
docker-compose run php-cli ./vendor/bin/phpunit Tests/
[25-Oct-2020 07:28:39 Asia/Tokyo] PHP Fatal error: Trait 'Symfony\Bridge\PhpUnit\ExpectDeprecationTrait' not found in /var/www/html/Tests/Controller/ContainerControllerResolverTest.php on line 21
docker-compose run composer ./vendor/bin/simple-phpunit
Install phpunit / phpunit from symfony / phpunit-bridge by running
File > Settings > Languages & Frameworks > PHP
Set phpstorm to run docker php
Click ... on the far right of the CLI interpreter
Click the additional + button and select From Docker, ...
Check Docker-compose and select the php service (php-cli in this case) to be executed from docker
If you press OK and php is loaded and version etc. is displayed, there is no problem
Phpunit File > Settings > Languages & Frameworks > PHP > Test Frameworks
Set phpstorm to run phpunit in docker
Select PHPUnit by Remote Interpreter from the additional + buttons
Select php-cli
`/ var / www / html / vendor / bin / simple-phpunit`
Select edit configuration with the selector on the left of the bug icon on the upper right of editor When the screen opens, select Phpunit from the additional + button and set as below
Paste the breakpoint and click the bug icon with simple-phpunit selected
Recommended Posts