-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
wp-env: Add Xdebug support #20636
Comments
I think that modifying the image the tool uses is a pretty straightforward/simple change -- could look something like this: {
"plugins": [ "." ],
"image": "foobar",
"testsImage": "foobar2"
} Would we want the And that would ultimately just change the string here:
We are trying to avoid exposing everything Docker has to offer, but I could see this as a simple way to integrate custom Docker stuff with the tool. cc @noisysocks if you have thoughts? |
why new config options, why not just reuse the |
Right now the |
I'd also encourage folks to resist adding config options when possible. Config options make things harder and more complex and as stated by the dev note, for complex use-cases, it's almost always better to rely on a custom docker-compose/custom tool. For instance, the example on the issue is about |
I would suggest adding a mechanism for activating/deactivating xDebug so it's installed and off by default, but with a way to activate it during times when you need to do code coverage or debug PHP, for example. |
I definitely agree. I was thinking that (in this case) specifying a Docker image might be a way to expose some more powerful features to advanced users without adding any extra burden to the simplicity of the tool. We definitely don't want to expose every Docker setting through tons of extra config options (i.e. specifying Docker However, I do see why adding it wouldn't be all good. A certain docker image may not fit well with the rest of the opinionated things that |
Definitely agree. The reason I considered alt Docker images is because xDebug is not in the core image. So if adding it means modifying some of your build script that is a win. But I'd also encourage the option to be able to turn it on or off. As for other more advanced uses, if the decision is to not extend
Absolutely. But if an alt Docker image is simply an extension of the core image, then all opinionated concerns that |
If this feature is considered...
If you are changing your primary image you usually have a good reason for doing so. Same would apply for a test image. In most cases |
Good discussion here, and thanks for using and testing I'm against allowing the Docker image to be customised because:
Developers that need to use a different Docker image can use their own Docker-based environment, and, this being GPLv2, can even use With that said, I agree that having Xdebug enabled in |
+1 on enabling Xdebug |
Going to rename this issue to track Xdebug support since that was the main goal of the original issue, and since we aren't going to add support for different docker images :) |
wp-env
package.
@noahtallen that's sufficient for my intention. If I need more I will create custom envs, but this will support a majority of my use cases at least. |
As @noisysocks mentioned, a possible solution is to change the image from I'm not sure if I understand the philosophy of docker completely, but since we are going to work with only one image. Apart from adding xdebug, would it make sense to also include PHPUnit and WPCLI in the image? For example, I use this Dockerfile for development on Linux: FROM wordpress:latest
LABEL maintainer Jules Colle <jules@bdwm.be>
RUN apt-get -y update; apt-get -y install curl; apt-get -y install wget;
# Install WP-CLI in the wordpress container
RUN curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar; ls -la; chmod +x ./wp-cli.phar; mv wp-cli.phar /usr/local/bin/wp-cli
# Install MySQL extension, as WP-CLI needs to access to WordPress database
RUN docker-php-ext-install mysqli
# Install PHPUnit in the container
RUN wget https://phar.phpunit.de/phpunit-7.5.9.phar; chmod +x phpunit-7.5.9.phar; mv phpunit-7.5.9.phar /usr/local/bin/phpunit; phpunit --version
# Install Xdebug
RUN pecl install "xdebug" \
&& docker-php-ext-enable xdebug
RUN echo "xdebug.remote_enable=1" >> /usr/local/etc/php/conf.d/xdebug.ini && \
echo "xdebug.remote_autostart=1" >> /usr/local/etc/php/conf.d/xdebug.ini && \
echo "xdebug.remote_port=9000" >> /usr/local/etc/php/conf.d/xdebug.ini && \
echo "xdebug.idekey=VSCODE" >> /usr/local/etc/php/conf.d/xdebug.ini && \
echo "xdebug.remote_host=172.17.0.1" >> /usr/local/etc/php/conf.d/xdebug.ini && \
echo "xdebug.remote_connect_back=0" >> /usr/local/etc/php/conf.d/xdebug.ini My guess is that this will only work on Linux though, cause I believe |
Something else I'm wondering about. If xdebug would be enabled, it would make sense to also know the path to the wordpress environment. wp-env seems to generate a kind of unpredictable path where it installs WP core, for example: I might be missing something obvious, but is there a way to make sure the wordpress core folder is always the same for a given project? For example while developing a plugin in a directory named |
Phpunit and WPCLI are included in some of the services (i.e. the CLI and phpunit services). But that does raise the question, why not use the same docker image for each service, each with the correct dependencies available? cc @epiqueras, not sure if you have ideas about that
So the path should be completely the same every time. Basically, it is just gutenberg/packages/env/lib/config/config.js Lines 64 to 66 in 87be0aa
IMO it would be nice to have this stuff working within wp-env so that the end user doesn't need to hack around with xdebug and install locations to get it working. But I admit I'm not super familiar with xdebug :) |
This would be very nice...i can explain a scenario where it can be very useful, when the wordpress core folder is configurable. For example when multiple developers are working on the same project and check it out on different project paths on their own system. This would generate an other md5 of the configPath. Something like WP_ENV_NAME could be used for the docker container name too, if this is wanted. This would be useful for xdebug support. |
I'm a little confused -- I think in your use case, if debugging core WordPress is necessary, why not map it to a local checkout via relative path? e.g. {
"core": "../wordpress-develop"
} You could also put that in If I'm not understand your use case, please let me know :) |
@noahtallen No, as i understand following block gutenberg/packages/env/lib/config/config.js Lines 64 to 67 in 87be0aa
it would combine the return value of getHomeDirectory, which would be the WP_ENV_HOME gutenberg/packages/env/lib/config/config.js Lines 315 to 319 in 87be0aa
with the md5 of the config path. This would result in This is exactly what is explained here |
Ah yeah, I see what you mean. Is there a reason to use that behavior rather than just mapping your own core source? |
This was fixed by #27346 apparently. |
Is your feature request related to a problem? Please describe.
The
wp-env
tool is a great way for developers to contribute to WordPress projects quickly. However, many agencies have workflows that don't use the official WordPress Docker image. An example would be to have a custom WordPress image that include tools likexDebug
or some custom scripts that execute upon launch.Describe the solution you'd like
It would be great if the
.wp-env.json
file included an option to load alternate images for the list of environments. Overriding thewordpress
orwordpress-test
images.Describe alternatives you've considered
Could possibly consider alternate
docker-compose.yml
files, or modifying the one produced bywp-env
.The text was updated successfully, but these errors were encountered: