Automatic detection of server proxy settings in PHP
I have a PHP script that is running on a windows server. The script creates a soapclient object that can be given proxy_host and proxy_port. Rather than hard-coding these values or making them a config option, I would like the PHP script to automatically detect the local server proxy settings so that if they change or if the script is running on another server, it just works. Does anyone know how to do this in PHP.
I don't think this is currently possible given the wide range of possible proxy configurations. Typically, components (like payment gateways) provide configuration options for proxy information (usually in the php.ini file) where you can set them. Otherwise, if you are working in a Nix based environment, you can try to get the environment settings for the current user using the following method:
http://us.php.net/manual/en/function.getenv.php
This way, if the server user changes the proxy settings, your script can pick it up and try to use it.
a source to share