|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #29280 Add php.ini option to set default proxy for wrappers
Submitted: 2004-07-20 14:01 UTC Modified: 2017-10-24 06:23 UTC
Avg. Score:4.3 ± 0.9
Reproduced:42 of 48 (87.5%)
Same Version:23 (54.8%)
Same OS:21 (50.0%)
From: Progman2002 at gmx dot de Assigned:
Status: Open Package: Streams related
PHP Version: * OS: *
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: Progman2002 at gmx dot de
New email:
PHP Version: OS:


 [2004-07-20 14:01 UTC] Progman2002 at gmx dot de
I'm behind a proxy so my local php version cannot access the internet directly. Every HTTP-Request must go throught the proxy. I have see that I can create my own http-wrapper with settings to use my proxy and use this metioned "context" as fourth parameter for the functions like fopen and file_get_contents. This works fine, but what about if I use third-party scripts, which just use file_get_contents($url) instead of file_get_contents($url, false, $context)? It is possible to change or modify the internal http-wrapper to use my proxy instead of creating a new http-wrapper with stream_*() so I can just use file_get_contents() and fopen() without the 'zcontext'-parameter?


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2004-07-20 14:24 UTC]
I know what you mean (and we do have something planned), but can you please clarify which functions you are using to implement proxy support?
 [2004-07-20 14:52 UTC] Progman2002 at web dot de
---- PHP-Code:
    $opts = array('http' => array('request_fulluri' => true,
                                  'proxy' => 'tcp://'));

    $context = stream_context_create($opts);

    $url = "";

    $fp = fopen($url, 'r', false, $context);
    if (!$fp) {
        echo "nothing :(";
    } else {

    // and now without $context...

    $fp = fopen($url, 'r');
    if (!$fp) {
        echo "nothing :(";
    } else {

The first call with $context works, the second doesnt:

---- Output:
resource(3) of type (stream) 
Warning: fopen( [function.fopen]: failed to open stream: Connection timed out in /home/progman/public_html/test.php on line 19
nothing :(

---- Expected:
resource(3) of type (stream)
resource(4) of type (stream) // or an other resource-id
A php.ini-setting for proxys would be maybe better ;)
 [2004-07-22 14:47 UTC]
Current CVS now has stream_context_get_default() which returns the default context used by all newly created streams (unless explicitly overriden).

You can use this in your script (perhaps via auto_prepend) to set the proxy globally.

I know; an ini option for the proxy would be a good idea too, so let's ask Sara really nicely if she wouldn't mind adding that.
 [2004-07-22 16:47 UTC] progman2002 at gmx dot de
works fine.
---- PHPs snip ----
$opts = array('http' => array('request_fulluri' => true,
                              'proxy' => 'tcp://'));
---- eos ----
works also as...
---- PHPs snip ----
$context = stream_context_get_default();
stream_context_set_option($context, 'http', 'proxy', 'tcp://');
stream_context_set_option($context, 'http', 'request_fulluri', true);
---- eos ----
... does

So, now I must wait until it is in the non-cvs package ;)
 [2004-07-24 06:17 UTC]
Dunno why this was assigned to me when wez implemented it :)

Closing it up.  You can either grab the snapshot from otherwise your wait will be until 5.1.0 is released.
 [2004-07-24 06:19 UTC]
Ack! My bad... didn't see your note about making it an .ini option :)

 [2008-06-04 19:07 UTC] r13ckj at gmail dot com
I was just wondering whether this has been implemented?

My problem is outlined here:

I've spent countless hours on this problem, so any help would be much appreciated.
 [2009-09-17 09:34 UTC] fuzzy76 at fuzzy76 dot net
Is that a yes or a no on the ini option? :) I need to use a proxy in my 
office, and this makes testing webapps really difficult.
 [2010-12-20 14:03 UTC]
-Summary: changing the default http-wrapper +Summary: Add php.ini option to set default proxy for wrappers -Package: Feature/Change Request +Package: Streams related -PHP Version: 5CVS +PHP Version: *
 [2011-04-05 11:29 UTC] play4fun_82 at yahoo dot com
Hi, i have the same problem. My solution was to pass through proxy server with cntml tunneling tool.
You configure cntml proxy to forward http request received on local host on a port to destination with proper authentication.

And in pear u just configure 
>pear config-set http_proxy

3128 - is port configuret in cntlm(it can be any other free port).
 [2017-10-24 06:23 UTC]
-Status: Assigned +Status: Open -Assigned To: pollita +Assigned To:
 [2019-04-23 07:49 UTC] m dot weinstein at swp dot de
It's 2019. Anything new on this issue?
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Tue Jun 25 09:01:26 2019 UTC