This bundle provides a simple integration of the "Buzz library" from Kris Wallsmith into Symfony2. Buzz is a lightweight PHP 5.3 library for issuing HTTP requests. You can find more information about Buzz on its dedicated page at https://github.com/kriswallsmith/Buzz.
<?php
$buzz = $this->container->get('buzz');The bundle provides a new buzz service that returns an instance of
Buzz\Browser.
To install this bundle, you'll need both the Buzz library and this bundle. Installation depends on how your project is setup:
If you're using the bin/vendors.php method to manage your vendor libraries,
add the following entries to the deps file at the root of your project file:
[buzz]
git=http://github.com/kriswallsmith/Buzz.git
[SensioBuzzBundle]
git=http://github.com/sensio/SensioBuzzBundle.git
target=bundles/Sensio/Bundle/BuzzBundle
Next, update your vendors by running:
$ ./bin/vendors installGreat! Now skip down to Step 2.
If you're managing your vendor libraries with submodules, simply add the two following submodules:
$ git submodule add git://github.com/kriswallsmith/Buzz.git vendor/buzz
$ git submodule add git://github.com/sensio/SensioBuzzBundle.git vendor/bundles/Sensio/Bundle/BuzzBundleFinally update your submodules:
$ git submodule init
$ git submodule updateAdd the following entries to your autoloader:
<?php
// app/autoload.php
$loader->registerNamespaces(array(
// ...
'Buzz' => __DIR__.'/../vendor/buzz/lib',
'Sensio' => __DIR__.'/../vendor/bundles',
));Finally, enable the bundle in the kernel:
<?php
// app/AppKernel.php
public function registerBundles()
{
$bundles = array(
// ...
new Sensio\Bundle\BuzzBundle\SensioBuzzBundle(),
);
}Congratulations! You're ready to use Buzz into Symfony2!
The only thing to do is to request the buzz service from the container to get
an instance of Buzz\Browser and start issuing HTTP requests:
<?php
$buzz = $this->container->get('buzz');
$response = $buzz->get('http://google.com');
echo $response->getContent();By default, this bundle configures Buzz to perform HTTP requests with the cURL extension. You must check that the cURL PHP extension is correctly installed on your platform:
$ php -i | grep curl