symfony / http-kernel with phpstorm & docker phpunit & xdebug

[1. Download Source](# 1-Download Source) [2.docker settings](# 2-docker settings) [3. phpstorm settings](# 3-phpstorm settings)

1. Download source

git clone https://github.com/symfony/http-kernel.git

2. docker settings

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
  1. Composer Install
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

Note

docker-compose run composer ./vendor/bin/simple-phpunit

Install phpunit / phpunit from symfony / phpunit-bridge by running

3. phpstorm settings

File > Settings > Languages & Frameworks > PHP

Set phpstorm to run docker php

Click ... on the far right of the CLI interpreter Screenshot from 2020-10-25 07-33-45.jpg

Click the additional + button and select From Docker, ... Screenshot from 2020-10-25 07-34-02.png

Check Docker-compose and select the php service (php-cli in this case) to be executed from docker Screenshot from 2020-10-25 07-34-26.png

If you press OK and php is loaded and version etc. is displayed, there is no problem Screenshot from 2020-10-25 07-34-43.png

Phpunit File > Settings > Languages & Frameworks > PHP > Test Frameworks

Set phpstorm to run phpunit in docker

Select PHPUnit by Remote Interpreter from the additional + buttons Screenshot from 2020-10-25 07-37-21.png

Select php-cli Screenshot from 2020-10-25 07-37-40.png

  1. Check Path to phpunit.phar in PHPUnit library
  2. Path to phpunit.phar `/ var / www / html / vendor / bin / simple-phpunit`
  3. Check the Test Runner Default configulation file and check `` `/var/www/html/phpunit.xml.dist```

Screenshot from 2020-10-25 10-00-25.png

Execute

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 Screenshot from 2020-10-25 09-56-18.png

Paste the breakpoint and click the bug icon with simple-phpunit selected

Screenshot from 2020-10-25 08-30-20.png

Recommended Posts

symfony / http-kernel with phpstorm & docker phpunit & xdebug
If you get stuck with PHPStorm and xdebug on docker. trouble shooting
Debug the VSCode + Docker + PHP development environment with XDebug.
Write solidly with PhpStorm
Launch MariaDB with Docker
Rails deploy with Docker
Run Pico with docker
Use Puphpeteer with Docker
Operate Emby with Docker
Try WildFly with Docker
Use ngrok with Docker
Run Payara with Docker
[Docker] Connection with MySQL
Php settings with Docker
Getting Started with Docker
Disposable PHP with Docker
Install Composer with Docker
Run phpunit on Docker