2017 © Pedro PelĂĄez
 

symfony-bundle behind-a-proxy-bundle

Add proxy parameters for CURL, SoapClient connection and PHP function using stream context.

image

cnerta/behind-a-proxy-bundle

Add proxy parameters for CURL, SoapClient connection and PHP function using stream context.

  • Wednesday, April 13, 2016
  • by waldo2188
  • Repository
  • 3 Watchers
  • 2 Stars
  • 342 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 1 Open issues
  • 7 Versions
  • 0 % Grown

The README.md

/!\ Repository not maintained and outdated /!\

Cnerta Behind A Proxy Bundle

Add proxy parameters for CURL, SoapClient connection and PHP function using stream context., (*1)

SensioLabsInsight, (*2)

Build Status Latest Stable Version Latest Unstable Version, (*3)

WARNING host_ssl configuration has been removed since version 2.0.0
For PHP 5.4 and below, please use the version 1 of the bundle, (*4)

Install the Bundle

  1. Add the sources in your composer.json
     "require": {
        // ...
        "cnerta/behind-a-proxy-bundle": "1.0.*"
    }
  1. Then add it to your AppKernel class::
    // in AppKernel::registerBundles()
    $bundles = array(
        // ...
        new Cnerta\BehindAProxyBundle\CnertaBehindAProxyBundle(),
        // ...
    );

Configuration

config.yml, (*5)


cnerta_behind_a_proxy: enabled: false # type: boulean, default value: false, desc: enabled (true), or desabled (false) the use of proxy host: 127.0.0.1 # type: string, default value: null, desc : this is the IP or URL of the proxy server port: 80 # type: mixed(string|int), default value: null, desc : this is the port of the proxy server login: myWonderfulLogin # type: string, default value: null, desc : this is the login for authentication against the proxy server password: myWonderfulLogin # type: string, default value: null, this is the password for authentication against the proxy server load_default_stream_context: false # type: boolean, default value: false, If you need to set the default proxy config global http: # Option set only for http request host_proxy: 127.0.0.1 # type: string, default value: null, desc : this is the IP or URL of the proxy server port_proxy: 80 # type: mixed(string|int), default value: null, desc : this is the port of the proxy server login_proxy: login # type: string, default value: null, desc : this is the login for authentication against the proxy server password_proxy: password # type: string, default value: null, this is the password for authentication against the proxy server request_fulluri: true # type: boulean, default value: false, desc: enabled (true), or desabled (false) the full uri option of context https: # Option set only for https request host_proxy: 127.0.0.1 # type: string, default value: null, desc : this is the IP or URL of the proxy server port_proxy: 80 # type: mixed(string|int), default value: null, desc : this is the port of the proxy server login_proxy: login # type: string, default value: null, desc : this is the login for authentication against the proxy server password_proxy: password # type: string, default value: null, this is the password for authentication against the proxy server request_fulluri: true # type: boulean, default value: false, desc: enabled (true), or desabled (false) the full uri option of context

Set configuration proxy for CURL

    use Symfony\Component\DependencyInjection\ContainerInterface;
    /**
     * @var \Symfony\Component\DependencyInjection\ContainerInterface
     */
    private $container;

    //...

    $s = curl_init();
    curl_setopt($s, CURLOPT_BINARYTRANSFER, true);
    curl_setopt($s, CURLOPT_FAILONERROR, true);
    curl_setopt($s, CURLOPT_RETURNTRANSFER, true);

    curl_setopt($s, CURLOPT_URL, $this->url);

    // Call cnerta.baproxy service and call the method setProxyForCURL
    // the CURL resource '$s' is passed by reference
    $container->get('cnerta.baproxy')->setProxyForCURL($s);

    curl_exec($s);
    $status = curl_getinfo($s, CURLINFO_HTTP_CODE);
    $error = curl_error($s);

    curl_close($s);

    if ($status == 401) {
        throw new \RuntimeException("Invalid Credencial to connect to WebService");
    } else if ($status == 404) {
        throw new \RuntimeException("Invalid URL to connect to WebService");
    } elseif ($status != 200) {
        throw new \RuntimeException($error);
    }

Set configuration proxy for SoapClient


use Symfony\Component\DependencyInjection\ContainerInterface; /** * @var \Symfony\Component\DependencyInjection\ContainerInterface */ private $container; //... $config = array( "trace" => true, "exceptions" => 0, "cache_wsdl" => WSDL_CACHE_NONE ); $container->get('cnerta.baproxy')->setProxyForSoapClient($config); $soapClient = new \SoapClient('http://www.somewhere.com/?wsdl', $config);

Get Parameters anywhere

    use Symfony\Component\DependencyInjection\ContainerInterface;
    /**
     * @var \Symfony\Component\DependencyInjection\ContainerInterface
     */
    private $container;

    //...

    $this->container->getParameter("cnerta_baproxy.enabled")
    $this->container->getParameter("cnerta_baproxy.host")
    $this->container->getParameter("cnerta_baproxy.port")
    $this->container->getParameter("cnerta_baproxy.host_ssl")
    $this->container->getParameter("cnerta_baproxy.login")
    $this->container->getParameter("cnerta_baproxy.password")
    $this->container->getParameter("cnerta_baproxy.http")
    $this->container->getParameter("cnerta_baproxy.https")

The Versions

13/04 2016

dev-master

9999999-dev

Add proxy parameters for CURL, SoapClient connection and PHP function using stream context.

  Sources   Download

MIT

The Requires

 

The Development Requires

symfony2 bundle proxy cnerta

13/04 2016

2.0.1

2.0.1.0

Add proxy parameters for CURL, SoapClient connection and PHP function using stream context.

  Sources   Download

MIT

The Requires

 

The Development Requires

symfony2 bundle proxy cnerta

13/04 2016

2.0.0

2.0.0.0

Add proxy parameters for CURL, SoapClient connection and PHP function using stream context.

  Sources   Download

MIT

The Requires

 

The Development Requires

symfony2 bundle proxy cnerta

26/08 2014

1.0.2

1.0.2.0

Add proxy parameters for CURL, SoapClient connection and PHP function using stream context.

  Sources   Download

MIT

The Requires

 

symfony2 bundle proxy cnerta

26/08 2014

1.0.1

1.0.1.0

Add proxy parameters for CURL, SoapClient connection and PHP function using stream context.

  Sources   Download

MIT

The Requires

 

symfony2 bundle proxy cnerta

13/11 2013

1.0.x-dev

1.0.9999999.9999999-dev

Add proxy parameters for CURL, SoapClient connection and PHP function using stream context.

  Sources   Download

MIT

The Requires

 

symfony2 bundle proxy cnerta

13/11 2013

1.0.0

1.0.0.0

Add proxy parameters for CURL, SoapClient connection and PHP function using stream context.

  Sources   Download

MIT

The Requires

 

symfony2 bundle proxy cnerta