简体   繁体   English

Xdebug: Windows + PhpStorm + Docker 桌面 + CodeIgniter

[英]Xdebug: Windows + PhpStorm + Docker Desktop + CodeIgniter

I created a new CodeIgniter project and need to setup debugging with Xdebug against a container running in Docker Desktop.我创建了一个新的 CodeIgniter 项目,需要使用 Xdebug 对在 Docker 桌面中运行的容器进行调试。 I'm not sure how to connect Xdebug to the container given my directory structure.给定我的目录结构,我不确定如何将 Xdebug 连接到容器。 I get an incoming connection dialog but not sure how to map it properly.我收到一个传入连接对话框,但不确定如何正确 map。

How do you map an incoming xdebug connection when your directory structure is split between a public folder which is the entry point for CodeIgniter and the rest of the CodeIgniter framework code in the server folder? How do you map an incoming xdebug connection when your directory structure is split between a public folder which is the entry point for CodeIgniter and the rest of the CodeIgniter framework code in the server folder? It looks like this:它看起来像这样:

[ [1 ] ]

I was able to successfully create and run a docker deployment in PhpStorm:我能够在 PhpStorm 中成功创建并运行 docker 部署:

Deploying 'Compose: docker'...
"C:\Program Files\Docker\Docker\resources\bin\docker-compose.exe" -f D:\Projects\my-project\devops\docker\docker-compose.yml up -d proxy database opp_web
opp_database is up-to-date
opp_proxy is up-to-date
opp_web is up-to-date
'Compose: docker' has been deployed successfully.

My docker-compose.yml file:我的docker-compose.yml文件:

version: "3"

networks:
  opp-proxy:
    driver: bridge
  default:

services:
  proxy:
    image: "jwilder/nginx-proxy:latest"
    container_name: "opp_proxy"
    volumes:
      - "dhparam:/etc/nginx/dhparam"
      - "./files/certs/:/etc/nginx/certs"
      - "/var/run/docker.sock:/tmp/docker.sock:ro"
    restart: "always"
    networks:
      - "opp-proxy"
    ports:
      - "80:80"
      - "443:443"

  database:
    image: mysql:5.7
    container_name: "opp_database"
    environment:
      MYSQL_ROOT_PASSWORD: password
      MYSQL_USER: dba
      MYSQL_PASSWORD: password
      MYSQL_DATABASE: opp
    volumes:
      - "db_data:/var/lib/mysql"
      - "./files/docker-entrypoint-initdb.d:/docker-entrypoint-initdb.d"
    ports:
      - "23306:3306"

  opp_web:
    image: webdevops/php-apache-dev:7.4
    container_name: "opp_web"
    volumes:
      - "./files/entrypoint.d:/entrypoint.d"
      - "../../server:/app"
    environment:
      VIRTUAL_HOST: "opp.test"
      WEB_DOCUMENT_ROOT: "/app/public"
      PHP_DEBUGGER: xdebug
      XDEBUG_MODE: "develop,debug"
      XDEBUG_START_WITH_REQUEST: trigger
      XDEBUG_CLIENT_PORT: 9002
      XDEBUG_CLIENT_HOST: "host.docker.internal"
      XDEBUG_DISCOVER_CLIENT_HOST: 'false'
    depends_on:
      - database
    networks:
      - default
      - opp-proxy

volumes:
  db_data:
  dhparam:

When I try to map the incoming connection I would prefer to use Import mappings from deployment as it auto-detects the deployment but not sure what the deployment root should be set to:当我尝试 map 传入连接时,我更喜欢使用从部署导入映射,因为它会自动检测部署,但不确定部署根应该设置为:

[ [2 ] ]

I also tried all of these files as entry points when it auto-detects the paths:当它自动检测路径时,我还尝试了所有这些文件作为入口点:

3

4

Assuming I use Manually choose local file or project , I set a breakpoint in the server/app/Controllers/Home.php controller (default CodeIgniter index method that returns the welcome message), the breakpoint never gets hit.假设我使用Manually select local file or project ,我在server/app/Controllers/Home.php controller 设置断点(默认 CodeIgniter 方法永远不会获得返回欢迎消息的断点索引) But if I set a breakpoint in the server/public/index.php I can step through successfully with the debugger.但是,如果我在server/public/index.php中设置断点,我可以使用调试器成功单步执行。 So there is some issue when the CodeIgniter framework gets run and doesn't debug into the app/Controllers/Home.php file even though the page loads successfully.因此,当 CodeIgniter 框架运行并且没有调试到app/Controllers/Home.php文件中时,即使页面加载成功,也会出现一些问题。 How can I debug into the app folder?如何调试到app文件夹?

Thanks to the comments from @LazyOne, I just needed to add a path for the server to be /app/ :感谢@LazyOne 的评论,我只需要为服务器添加一个路径即可/app/

1

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM