4
5

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Docker(Nginx + php-fpm-alpine) + Laravel(6.0)をXdebugでステップ実行する

Last updated at Posted at 2019-10-18

背景

タイトルどおり

前提条件

OSはmacOS Mojave
Docker(Nginx + php-fpm-alpine) + Laravel(6.0)の環境構築ができていること
Laravelのローカル環境をDockerを利用してSSLからLaravel Duskの設定まであたりを参考に。

php.iniの編集(追記)

php.ini
[xdebug]
xdebug.remote_enable=1
xdebug.remote_autostart=1
xdebug.remote_host="host.docker.internal"
xdebug.remote_port=9012
xdebug.remote_log=/var/log/xdebug.log

php.iniをマウント設定

docker-compose.yml

#省略
  php-fpm:
    build: ./php-fpm
    ports:
      - 9000:9000
    volumes:
      - ../_docker-configs/xdebug/php.ini:/usr/local/etc/php/php.ini
#省略

Dockerfileの編集(追記)

php-alpineコンテナにxdebugをインストールする時にハマったメモを参考に


# 追記
RUN apk add autoconf build-base
RUN pecl install xdebug
RUN docker-php-ext-enable xdebug

VSCodeのlaunch.jsonの編集

launch.json
{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Listen for XDebug",
            "type": "php",
            "request": "launch",
            "port": 9012,
            "pathMappings": {
                "/var/www/html": "${workspaceFolder}"
            },
            "ignore": [
                "**/vendor/**/*.php"
            ]
        }
    ]
}

あとはブレークポイントを貼ってステップ実行できればおk。

スクリーンショット 2019-10-18 16.22.36.png

参考

Dockerで作るNginx + PHP7 + Xdebug環境

4
5
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
5

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?