ddeboer / GuzzleBundle

A Symfony2 bundle for integrating Guzzle, a PHP framework for building RESTful web service clients
63 stars 29 forks source link

Update for latest Guzzle and symfony log support #7

Closed gimler closed 12 years ago

gimler commented 12 years ago

Upgrade bundle to be compatible with the latest guzzle version.

Better integration and support for symfony log ;)

fix #5 #6

xyanide commented 12 years ago

I got your version of the bundle working with the latest version of guzzle, and its working great. The only thing im missing is the logger in the Symfony profiler. It shows no requests in the profiler, even though i`m making several requests.

Could you show how to enable to logging for the guzzle bundle?

gimler commented 12 years ago

Did you see the Point Guzzle in the debug toolbar? Do you use the service "guzzle.service_builder" to build your clients?

xyanide commented 12 years ago

I`m not seeing guzzle in the toolbar. I am seeing guzzle in the profiler page, which is showing 'No requests sent'.

Im not using the guzzle.service.builder to build my clients, im using a custom client that initializes the guzzle client.

gimler commented 12 years ago

Thats the problem you must use the service or see service.xml file attach the plugins manually. When you use the service it attach the plugins automatically.

xyanide commented 12 years ago

Could you show what could would be required to enable the dataCollector?

Something like this is not working yet: $this->apiClient = new Client($apiLocation); $dataCollector = new DataCollectorPlugin(); $this->apiClient->addSubscriber($dataCollector);

Error given: Call to undefined method Guzzle\Http\Message\EntityEnclosingRequest::getResourceUri(). Line 92 in the dataCollectorPlugin.

gimler commented 12 years ago

you forgot to add the Guzzle\Common\Log\ArrayLogAdapter to the dataCollectorPlugin try

$dataCollector = new DataCollectorPlugin(new Guzzle\Common\Log\ArrayLogAdapter());
$this->apiClient->addSubscriber($dataCollector);
xyanide commented 12 years ago

When I do that the error from my message above still appears. When commenting that line the site is working, but i`m not seeing any requests in the profiler?

The plugin does seem to be called and the requests go through the plugin.

gimler commented 12 years ago

ahh yes sorry you must use the service "guzzle.plugin.log.array.adapter" so this is use in the collector

$logAdapter = $this->container->get('guzzle.plugin.log.array.adapter');
$this->apiClient->addSubscriber($logAdapter);
xyanide commented 12 years ago

When i add that line my session gets killed and the setLocale function for the session stops working :/. (session = null) Any clue?

gimler commented 12 years ago

Check if logging is enabled. When i find some time i can add a example for this.

mtdowling commented 12 years ago

@gimler I made a breaking change a few versions ago that renamed getResourceUri() to getResource(). This might be part of the problem.

clicktrend commented 12 years ago

+1 Waiting for merge

arturmartins commented 12 years ago

+1

predakanga commented 12 years ago

I'm definitely in favour of getting the rewrite merged, but it's not working for me and I'm not sure how it's working for others.

When retrieving the service builder, I get the following:

Catchable Fatal Error: Argument 2 passed to Guzzle\Service\Builder\ServiceBuilder::factory() must be an array, object given in /Users/lachlan/Development/BTNv2/vendor/guzzle/guzzle/src/Guzzle/Service/Builder/ServiceBuilder.php line 45

I've checked various versions of Guzzle itself and in all recent versions this is the case.

Sidenote: I've added a composer.json in my own fork, will add that in once I figure this out

gimler commented 12 years ago

i have checked this and it works with the latest guzzle version c8b3c4c3d07c3469dd7bfc758e1e631a723e3bb7

i think you use the deprecated cache configuration please use the guzzle client cache not this provided by the bundle. There is a PR for remove the old cache logic https://github.com/ddeboer/GuzzleBundle/pull/2

predakanga commented 12 years ago

Thanks @gimler - that was indeed the case. I was working on a simple checkout of your branch - it's gotten a bit messy around here with the various pull requests.

gimler commented 12 years ago

https://github.com/ddeboer/GuzzleBundle/issues/8 vote for this please ;)