PHPackages                             metaer/curl-wrapper-bundle - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [HTTP &amp; Networking](/categories/http)
4. /
5. metaer/curl-wrapper-bundle

ActiveSymfony-bundle[HTTP &amp; Networking](/categories/http)

metaer/curl-wrapper-bundle
==========================

Curl wrapper bundle

1.0.6(5y ago)211.4k↓31.3%1[1 issues](https://github.com/metaer/curl-wrapper-bundle/issues)MITPHPPHP &gt;=7.0

Since Jan 12Pushed 3y ago1 watchersCompare

[ Source](https://github.com/metaer/curl-wrapper-bundle)[ Packagist](https://packagist.org/packages/metaer/curl-wrapper-bundle)[ Docs](https://github.com/metaer/curl-wrapper-bundle)[ RSS](/packages/metaer-curl-wrapper-bundle/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (2)Versions (14)Used By (0)

[![Build Status](https://camo.githubusercontent.com/00d962931532dc904e078e609ae45b17eb875f00db67eb9fae798b0fce9609dc/68747470733a2f2f7472617669732d63692e6f72672f6d65746165722f6375726c2d777261707065722d62756e646c652e706e673f6272616e63683d6d6173746572)](https://travis-ci.org/metaer/curl-wrapper-bundle)

Curl wrapper bundle
===================

[](#curl-wrapper-bundle)

Curl Wrapper bundle for symfony framework

Installation
------------

[](#installation)

```
composer require metaer/curl-wrapper-bundle
```

If you use Symfony 4+ with symfony flex - that's all
If you use Symfony 2 or 3 (without symfony flex), add to AppKernel.php:

```
new \Metaer\CurlWrapperBundle\MetaerCurlWrapperBundle(),
```

Basic Usage
-----------

[](#basic-usage)

```
$options = [
    CURLOPT_URL => 'http://example.ex',
    CURLOPT_RETURNTRANSFER => true,
];

$cw = $container->get('metaer_curl_wrapper.curl_wrapper');

try {
    $result = $cw->getQueryResult($options);
} catch (CurlWrapperException $e) {
    //handle exception
}
```

Basic usage with injection into your controller:
------------------------------------------------

[](#basic-usage-with-injection-into-your-controller)

```
MyController {
    /**
     * @var CurlWrapper
     */
    private $curlWrapper;

    /**
     * MyController constructor.
     * @param CurlWrapper $curlWrapper
     */
    public function __construct(CurlWrapper $curlWrapper)
    {
        $this->curlWrapper = $curlWrapper;
    }

    public function myAction() {
        $options = [
            CURLOPT_URL => 'http://example.ex',
            CURLOPT_RETURNTRANSFER => true,
        ];

        try {
            $this->curlWrapper->getQueryResult($options);
        } catch (CurlWrapperException $e) {
            //handle exception
        }

        return new Response('something');
    }
}
```

Basic usage with controllers action argument:
---------------------------------------------

[](#basic-usage-with-controllers-action-argument)

```
MyController {
    public function myAction(CurlWrapper $curlWrapper) {
        $options = [
            CURLOPT_URL => 'http://example.ex',
            CURLOPT_RETURNTRANSFER => true,
        ];

        try {
            $result = $curlWrapper->getQueryResult($options);
        } catch (CurlWrapperException $e) {
            //handle exception
        }

        return new Response('something');
    }
}
```

Basic Usage with autowire in another service:
---------------------------------------------

[](#basic-usage-with-autowire-in-another-service)

```
