1. Go to this page and download the library: Download metaer/curl-wrapper-bundle library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
php
namespace App\Service;
use Metaer\CurlWrapperBundle\CurlWrapper;
use Metaer\CurlWrapperBundle\CurlWrapperException;
class MyService
{
/**
* @var CurlWrapper
*/
private $curlWrapper;
/**
* MyService constructor.
* @param CurlWrapper $curlWrapper
*/
public function __construct(CurlWrapper $curlWrapper)
{
$this->curlWrapper = $curlWrapper;
}
public function myMethod() {
$options = [
CURLOPT_URL => 'http://example.ex',
CURLOPT_RETURNTRANSFER => true,
];
try {
$result = $this->curlWrapper->getQueryResult($options);
} catch (CurlWrapperException $e) {
//handle exception
}
}
}
php
// src/MyCurlWrapper.php
namespace App;
use Metaer\CurlWrapperBundle\CurlWrapper;
class MyCurlWrapper extends CurlWrapper
{
public function getQueryResult(array $curlOptions)
{
//your code here
return 'something';
}
public function myCustomMethod()
{
//something else
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.