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

PHP 8, Docker and VS Code #94

Closed
intellent opened this issue Feb 19, 2021 · 5 comments
Closed

PHP 8, Docker and VS Code #94

intellent opened this issue Feb 19, 2021 · 5 comments

Comments

@intellent
Copy link

I am trying to get yasd running on PHP 8 inside Docker with VS Code in my Docker host.

My Dockerfile:

FROM php:8-cli

# Install yasd (XDebug alternative) and Swoole and use the default development configuration
RUN apt-get update && apt-get install -y dumb-init libboost-all-dev \
    && pecl install swoole \
    && docker-php-ext-enable swoole \
    && cd /tmp \
    && curl -L https://github.com/swoole/yasd/archive/v0.3.7.tar.gz --output yasd.tar.gz \
    && mkdir yasd && tar xzf yasd.tar.gz -C yasd --strip-components 1 \
    && cd yasd \
    && phpize --clean \
    && phpize \
    && ./configure \
    && make clean \
    && make \
    && make install \
    && cd / && rm -rf /tmp/* \
    && mv "$PHP_INI_DIR/php.ini-development" "$PHP_INI_DIR/php.ini"

# Add additional php.ini confs
COPY ./res/service-config/php/conf.d/*.ini /usr/local/etc/php/conf.d/

ENTRYPOINT ["/usr/bin/dumb-init", "--", "php", "-e"]

My yasd.ini:

zend_extension=yasd
yasd.debug_mode=remote
yasd.remote_host=host.docker.internal
yasd.remote_port=9000

My launch.json for VS Code:

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Listen for XDebug",
            "type": "php",
            "request": "launch",
            "port": 9000,
            "pathMappings": {
                "/opt/my-app": "${workspaceRoot}"
            },
        }
    ]
}

When running my container, I instantly get the error:

Invalid address/ Address not supported: Function not implemented

If I remove the -e argument from the PHP call, my service starts and works fine. However, debugging from VS Code does not work (breakpoints not detected).

Any hints what else I can try?

@huanghantao
Copy link
Member

You should use IP instead of host.docker.internal.

@intellent
Copy link
Author

You should use IP instead of host.docker.internal.

Oh, okay. Afaik the internal IP of the Docker host is not static.

@huanghantao
Copy link
Member

Thanks for your feedback, I will support the domain name in the next version.

@huanghantao
Copy link
Member

huanghantao commented Mar 4, 2021

Hi, we can use debug init file to set the remote_host. #98 #97

@volodymyr-hordiienko
Copy link

volodymyr-hordiienko commented Feb 1, 2022

@huanghantao @intellent which ip should I use inside a docker? host.docker.internal, 127.0.0.1, 0.0.0.0 not working for me

host.docker.internal shows me error - [yasd] recv command error, connection closed
but 127.0.0.1, 0.0.0.0 - [yasd] Connect IDE failed (Connection refused), please check that the IDE is in a listening state

could you help me please?

FROM hyperf/hyperf:8.0-alpine-v3.15-swoole

RUN set -ex \
    && apk add $PHPIZE_DEPS \
        openssl-dev \
        boost-dev \
    && ln -sf /usr/bin/phpize8 /usr/local/bin/phpize \
    && ln -sf /usr/bin/php-config8 /usr/local/bin/php-config

RUN git clone https://github.com/swoole/yasd.git \
    && cd yasd \
    && phpize --clean \
    && phpize \
    && ./configure \
    && make clean \
    && make \
    && make install

RUN echo "extension=yasd.so" > /etc/php8/conf.d/50_yasd.ini \
    && echo "yasd.debug_mode=remote" >> /etc/php8/conf.d/50_yasd.ini \
    && echo "yasd.remote_host=host.docker.internal" >> /etc/php8/conf.d/50_yasd.ini \
    && echo "yasd.remote_port=9000" >> /etc/php8/conf.d/50_yasd.ini

WORKDIR /data/project

COPY entrypoint.sh /scripts/entrypoint.sh
RUN chmod +x /scripts/entrypoint.sh

ENTRYPOINT ["/scripts/entrypoint.sh"]

Hyperf 2.2 scan_cacheable=true

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