wernerdweight / curler-bundle
Symfony bundle wrapper for wernerdweight/curler.
Installs: 9
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 3
Forks: 0
Open Issues: 2
Type:symfony-bundle
Requires
- php: >=7.2.0
- symfony/framework-bundle: ^4.0
- wernerdweight/curler: ^1.0
Requires (Dev)
- wernerdweight/cs: ^1.3
This package is auto-updated.
Last update: 2024-10-29 05:28:40 UTC
README
This bundle wraps Curler into Symfony Bundle.
Installation
- Download using composer
composer require wernerdweight/curler-bundle
- Enable the bundle
Enable the bundle in your kernel:
<?php // config/bundles.php return [ // ... WernerDweight\CurlerBundle\CurlerBundle::class => ['all' => true], ];
- Use in your project
use WernerDweight\Curler\Curler; use WernerDweight\Curler\Request; class MyService { /** Curler */ private $curler; /** * @param Curler $curler */ public function __construct(Curler $curler) { $this->curler = $curler; } public function myAction(): void { $request = (new Request()) ->setEndpoint('https://some-website.tld') ->setMethod('POST') ->setPayload(['key' => 'value']) ->setHeaders(['Accept: text/html', 'Accept-Encoding: gzip']) ->setAuthentication('user', 'password') ; $response = $this->curler->request($request); echo $response->text(); // '<html>...</html>' var_dump($response->getMetaData()); // array of response metadata (content-type, status...) } }
License
This bundle is under the MIT license. See the complete license in the root directiory of the bundle.