You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This would configure the proxy for HTTP requests in core when using WP-CLI, similar to when you define this in wp-config.php. The setup would be slightly more complex for modifying HTTP requests from WP-CLI itself.
I looked into this and also checked the existing draft PR #623 and the closed PR #636.
I think I can take a try at completing this, if that works for maintainers.
The main missing piece seems to be the WP-CLI-specific HTTP request handling. I verified locally that WP-CLI's own HTTP requests go through the http_request_options hook, not http_request_args. I also tested the Requests proxy format locally: normalizing an env value like http://127.0.0.1:8080 to 127.0.0.1:8080 works across the Requests proxy handling, while passing the raw URL can fail with the fsockopen transport.
My plan would be to document both cases:
WordPress core HTTP requests using WP_PROXY_HOST, WP_PROXY_PORT, and optional auth constants.
WP-CLI's own HTTP requests using WP_CLI::add_hook( 'http_request_options', ... ), with proxy env vars normalized to Requests' host:port format.
I would also include support for HTTPS_PROXY, https_proxy, HTTP_PROXY, and http_proxy, as suggested in the review on #623.
I wanted to find some time to continue #623 for a while now. As you noticed, covering the settings for both types of HTTP requests involves quite some code. So I was tinkering with the idea of making this easier to use, for example through a new WP-CLI package or perhaps even some config in the framework itself. Then one doesn't have to copy all this stuff from documentation :)
I did another pass locally and found a cleaner path than a long docs-only example.
My current recommendation is to prototype a small WP-CLI package first, then add short handbook docs around that package if the direction looks good.
Reason: WP-CLI already keeps unknown config keys in extra_config, so a package can read a simple opt-in config block from wp-cli.yml without needing framework changes first.
Example config could be:
http-proxy:
url: http://proxy.example.com:8080
or:
http-proxy:
host: proxy.example.com
port: 8080
I tested this locally with a package-style loader. The loader can read http-proxy from WP_CLI::get_runner()->extra_config, normalize the proxy into Requests' host:port format, define the WordPress core proxy constants, and hook WP-CLI's own HTTP requests through http_request_options.
The local checks covered:
WordPress core constants: WP_PROXY_HOST, WP_PROXY_PORT, optional auth, and WP_PROXY_BYPASS_HOSTS.
WP-CLI internal HTTP requests via WP_CLI::add_hook( 'http_request_options', ... ).
url config and host / port config.
URL-encoded proxy auth.
fsockopen transport, where normalized host:port works.
--skip-packages as an escape hatch.
So my updated read is that a small package is probably the best first step. It avoids asking users to copy a large proxy.php file from the docs, and it avoids a framework-level config change until maintainers decide this should become built in.
Would you prefer that I prototype the package approach first?
My current read is that the package approach is the best first step: it keeps this opt-in, avoids a large copy/paste docs example, and avoids changing WP-CLI framework config before we know the shape is right.
One important detail from the prototype: installing the package alone should not trust proxy env vars. It should require explicit config, with env lookup only when users set something like env: true.
The local prototype supports config by url or host/port, optional auth, bypass hosts, WordPress core proxy constants, and WP-CLI HTTP requests via http_request_options.
Would you prefer that I clean this up as a package PR/repo next, or share the prototype first?
I added a first Behat test suite to the prototype.
It now covers the opt-in config paths, env vars only when enabled, WordPress proxy constants, local proxy request handling, bypass hosts, and a clean error when the proxy is unreachable.
There's also #654, let's merge efforts of possible.
Not merging anything for now
Thanks @swissspidy Understood, happy to merge efforts with #654.
I compared both PRs. #658 adds cross-links in references/config.md and guides/troubleshooting.md on top of the main guide. Let me know whether you'd
prefer I:
Activity
eddyd97-sudo commentedon Dec 7, 2025
eddyd97-sudo commentedon Dec 7, 2025
eddyd97-sudo commentedon Dec 7, 2025
eddyd97-sudo commentedon Dec 7, 2025
ekamran commentedon May 24, 2026
I looked into this and also checked the existing draft PR #623 and the closed PR #636.
I think I can take a try at completing this, if that works for maintainers.
The main missing piece seems to be the WP-CLI-specific HTTP request handling. I verified locally that WP-CLI's own HTTP requests go through the
http_request_optionshook, nothttp_request_args. I also tested the Requests proxy format locally: normalizing an env value likehttp://127.0.0.1:8080to127.0.0.1:8080works across the Requests proxy handling, while passing the raw URL can fail with the fsockopen transport.My plan would be to document both cases:
WP_PROXY_HOST,WP_PROXY_PORT, and optional auth constants.WP_CLI::add_hook( 'http_request_options', ... ), with proxy env vars normalized to Requests'host:portformat.I would also include support for
HTTPS_PROXY,https_proxy,HTTP_PROXY, andhttp_proxy, as suggested in the review on #623.Would you be open to a fresh PR for this?
swissspidy commentedon May 25, 2026
Appreciate the research & help!
I wanted to find some time to continue #623 for a while now. As you noticed, covering the settings for both types of HTTP requests involves quite some code. So I was tinkering with the idea of making this easier to use, for example through a new WP-CLI package or perhaps even some config in the framework itself. Then one doesn't have to copy all this stuff from documentation :)
ekamran commentedon May 25, 2026
Thanks, that makes sense.
I agree that a long copy/paste
proxy.phpexample in the docs may not be the best final user experience.Would it be helpful if I first explore the possible directions and report back before opening a PR?
The options I can compare are:
I can do the investigation first and share a proposed path before writing the PR.
swissspidy commentedon May 25, 2026
That would be excellent, thank you!
ekamran commentedon May 25, 2026
I did another pass locally and found a cleaner path than a long docs-only example.
My current recommendation is to prototype a small WP-CLI package first, then add short handbook docs around that package if the direction looks good.
Reason: WP-CLI already keeps unknown config keys in extra_config, so a package can read a simple opt-in config block from wp-cli.yml without needing framework changes first.
Example config could be:
or:
I tested this locally with a package-style loader. The loader can read http-proxy from WP_CLI::get_runner()->extra_config, normalize the proxy into Requests' host:port format, define the WordPress core proxy constants, and hook WP-CLI's own HTTP requests through http_request_options.
The local checks covered:
So my updated read is that a small package is probably the best first step. It avoids asking users to copy a large proxy.php file from the docs, and it avoids a framework-level config change until maintainers decide this should become built in.
Would you prefer that I prototype the package approach first?
swissspidy commentedon May 25, 2026
Sure, why not! Always good to have something runnable to verify the implementation, and this could be linked to from the docs as well.
ekamran commentedon May 25, 2026
I built a local package prototype and tested it.
My current read is that the package approach is the best first step: it keeps this opt-in, avoids a large copy/paste docs example, and avoids changing WP-CLI framework config before we know the shape is right.
One important detail from the prototype: installing the package alone should not trust proxy env vars. It should require explicit config, with env lookup only when users set something like env: true.
The local prototype supports config by url or host/port, optional auth, bypass hosts, WordPress core proxy constants, and WP-CLI HTTP requests via http_request_options.
Would you prefer that I clean this up as a package PR/repo next, or share the prototype first?
swissspidy commentedon May 25, 2026
If you have a repo to share that would be great :)
ekamran commentedon May 25, 2026
Sure, I put the prototype here:
https://github.com/ekamran/wp-cli-http-proxy-command
It is still rough, but it shows the package direction with opt-in config and runnable status/check commands.
swissspidy commentedon May 25, 2026
Awesome, thanks!
I just shared it in some of the related issues about this topic. Hopefully there will be some feedback :)
At first glance it would be cool if there were Behat test to verify that the command works as extended. Not sure how feasible it would be though.
But if the package works well, we can definitely simply link to that in the handbook.
ekamran commentedon May 26, 2026
I added a first Behat test suite to the prototype.
It now covers the opt-in config paths, env vars only when enabled, WordPress proxy constants, local proxy request handling, bypass hosts, and a clean error when the proxy is unreachable.
Local composer test is passing.
dilipom13 commentedon Aug 2, 2026
Hello @swissspidy
Opened PR #658 for this.
Adds
guides/http-proxy.mddocumenting:ekamran/wp-cli-http-proxy-commandPlease review it.
Thank you.
swissspidy commentedon Aug 2, 2026
There's also #654, let's merge efforts of possible.
Not merging anything for now
dilipom13 commentedon Aug 2, 2026
Thanks @swissspidy Understood, happy to merge efforts with #654.
I compared both PRs. #658 adds cross-links in
references/config.mdandguides/troubleshooting.mdon top of the main guide. Let me know whether you'dprefer I:
I'll wait for your direction before making further changes.