Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wsl2+docker 环境 下remote模式,开启调试 显示错误 #118

Closed
zyimm opened this issue Apr 27, 2021 · 4 comments
Closed

wsl2+docker 环境 下remote模式,开启调试 显示错误 #118

zyimm opened this issue Apr 27, 2021 · 4 comments
Assignees

Comments

@zyimm
Copy link

zyimm commented Apr 27, 2021

环境 wsl2+docker

PHP 7.4.9 (cli) (built: Aug 6 2020 19:45:55) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
with Yasd v0.3.7, Our Copyright, by codinghuang

IDE: PHPSTORM

PHP ini 配置

[yasd]
yasd.debug_mode=remote
yasd.remote_host=host.docker.internal
yasd.remote_port=9000

进入目录执行调试
报了 Invalid address/ Address not supported: No error information 错误

/www/2021/mermber-center # php -e bin/hyperf.php start
Invalid address/ Address not supported: No error information

想请教一下,这个错误是指的是我哪个地方的地址配错了? 因为这个错误提示不是很明确,无法确定如何配置?

@zyimm
Copy link
Author

zyimm commented Apr 28, 2021

自己琢磨一下:
Invalid address/ Address not supported: No error information 这个错误
可以使用 init_file 添加 setRemoteHost 解决。
然而 swoole 没有启动,也没有任何报错。

/www/2021/mermber-center # php -e bin/hyperf.php start
[yasd] execute init_file success


希望作者完善文档吧,目前在docker下确实不知道怎么使用?

@huanghantao
Copy link
Member

加我微信: codinghuang

@leocavalcante
Copy link
Member

If someone else gets here, I got this working by replacing the remote_host at the ENTRYPOINT:

docker-entrypoint.sh
#!/usr/bin/env sh
echo "yasd.remote_host=$(getent hosts host.docker.internal | awk '{print $1}')" >> "$PHP_INI_DIR/conf.d/99_overrides.ini"
php "$@"
Dockerfile
FROM phpswoole/swoole:4.6-php7.4-alpine
RUN apk add boost-dev

RUN wget -c https://github.com/swoole/yasd/archive/refs/tags/v0.3.7.tar.gz -O - | tar -xz \
    && docker-php-source extract \
    && mv yasd-0.3.7 /usr/src/php/ext/yasd \
    && docker-php-ext-install yasd

RUN { \
    echo "yasd.debug_mode=remote"; \
    echo "yasd.remote_host=0.0.0.0"; \
    echo "yasd.remote_port=9000"; \
} | tee "$PHP_INI_DIR/conf.d/99_overrides.ini"

ADD docker-entrypoint.sh /docker-entrypoint.sh
ENTRYPOINT [ "sh", "-c", "/docker-entrypoint.sh" ]
docker-compose.yml
version: '3.8'
services:
  dev:
    container_name: coroutine_context_api
    tty: true
    build: .
    volumes:
      - ./:/var/www
    environment:
      - PHP_IDE_CONFIG=serverName=CoroutineContextAPI

The PHP_IDE_CONFIG is important to have your paths mapped.

@zyimm
Copy link
Author

zyimm commented May 13, 2021

If someone else gets here, I got this working by replacing the remote_host at the ENTRYPOINT:

docker-entrypoint.sh
#!/usr/bin/env sh
echo "yasd.remote_host=$(getent hosts host.docker.internal | awk '{print $1}')" >> "$PHP_INI_DIR/conf.d/99_overrides.ini"
php "$@"
Dockerfile
FROM phpswoole/swoole:4.6-php7.4-alpine
RUN apk add boost-dev

RUN wget -c https://github.com/swoole/yasd/archive/refs/tags/v0.3.7.tar.gz -O - | tar -xz \
    && docker-php-source extract \
    && mv yasd-0.3.7 /usr/src/php/ext/yasd \
    && docker-php-ext-install yasd

RUN { \
    echo "yasd.debug_mode=remote"; \
    echo "yasd.remote_host=0.0.0.0"; \
    echo "yasd.remote_port=9000"; \
} | tee "$PHP_INI_DIR/conf.d/99_overrides.ini"

ADD docker-entrypoint.sh /docker-entrypoint.sh
ENTRYPOINT [ "sh", "-c", "/docker-entrypoint.sh" ]
docker-compose.yml
version: '3.8'
services:
  dev:
    container_name: coroutine_context_api
    tty: true
    build: .
    volumes:
      - ./:/var/www
    environment:
      - PHP_IDE_CONFIG=serverName=CoroutineContextAPI

The PHP_IDE_CONFIG is important to have your paths mapped.

Yes, thank you! It's working

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants