File tree Expand file tree Collapse file tree 13 files changed +75
-17
lines changed Expand file tree Collapse file tree 13 files changed +75
-17
lines changed Original file line number Diff line number Diff line change 5050 "nyholm/nsa" : " ^1.1" ,
5151 "nyholm/psr7" : " ^1.2.1" ,
5252 "php-http/cache-plugin" : " ^1.7" ,
53- "php-http/guzzle6 -adapter" : " ^1.1.1 || ^2.0 .1" ,
53+ "php-http/guzzle7 -adapter" : " ^0.1 .1" ,
5454 "php-http/mock-client" : " ^1.2" ,
5555 "php-http/promise" : " ^1.0" ,
5656 "polishsymfonycommunity/symfony-mocker-container" : " ^1.0" ,
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ declare (strict_types=1 );
4+
5+ namespace Http \HttplugBundle \ClientFactory ;
6+
7+ use Http \Adapter \Guzzle7 \Client ;
8+
9+ /**
10+ * @author Tobias Nyholm <[email protected] > 11+ */
12+ class Guzzle7Factory implements ClientFactory
13+ {
14+ /**
15+ * {@inheritdoc}
16+ */
17+ public function createClient (array $ config = [])
18+ {
19+ if (!class_exists ('Http\Adapter\Guzzle7\Client ' )) {
20+ throw new \LogicException ('To use the Guzzle7 adapter you need to install the "php-http/guzzle6-adapter" package. ' );
21+ }
22+
23+ return Client::createWithConfig ($ config );
24+ }
25+ }
Original file line number Diff line number Diff line change 7272 <argument type =" service" id =" httplug.collector.formatter" />
7373 <argument type =" service" id =" debug.stopwatch" />
7474 </service >
75+ <service id =" httplug.collector.factory.guzzle7" class =" Http\HttplugBundle\Collector\ProfileClientFactory" decorates =" httplug.factory.guzzle7" public =" false" >
76+ <argument type =" service" id =" httplug.collector.factory.guzzle7.inner" />
77+ <argument type =" service" id =" httplug.collector.collector" />
78+ <argument type =" service" id =" httplug.collector.formatter" />
79+ <argument type =" service" id =" debug.stopwatch" />
80+ </service >
7581 <service id =" httplug.collector.factory.react" class =" Http\HttplugBundle\Collector\ProfileClientFactory" decorates =" httplug.factory.react" public =" false" >
7682 <argument type =" service" id =" httplug.collector.factory.react.inner" />
7783 <argument type =" service" id =" httplug.collector.collector" />
Original file line number Diff line number Diff line change 9090 <argument type =" service" id =" httplug.message_factory" />
9191 </service >
9292 <service id =" httplug.factory.guzzle6" class =" Http\HttplugBundle\ClientFactory\Guzzle6Factory" public =" false" />
93+ <service id =" httplug.factory.guzzle7" class =" Http\HttplugBundle\ClientFactory\Guzzle7Factory" public =" false" />
9394 <service id =" httplug.factory.react" class =" Http\HttplugBundle\ClientFactory\ReactFactory" public =" false" >
9495 <argument type =" service" id =" httplug.message_factory" />
9596 </service >
Original file line number Diff line number Diff line change 44
55namespace Http \HttplugBundle \Tests \Unit \DependencyInjection \Compiler ;
66
7- use Http \Adapter \Guzzle6 \Client ;
7+ use Http \Adapter \Guzzle7 \Client ;
88use Http \Client \HttpAsyncClient ;
99use Http \Client \HttpClient ;
1010use Http \Discovery \HttpClientDiscovery ;
Original file line number Diff line number Diff line change 1111 'stream_factory ' => 'my_stream_factory ' ,
1212 ],
1313 'classes ' => [
14- 'client ' => 'Http\Adapter\Guzzle6 \Client ' ,
14+ 'client ' => 'Http\Adapter\Guzzle7 \Client ' ,
1515 'message_factory ' => 'Http\Message\MessageFactory\GuzzleMessageFactory ' ,
1616 'uri_factory ' => 'Http\Message\UriFactory\GuzzleUriFactory ' ,
1717 'stream_factory ' => 'Http\Message\StreamFactory\GuzzleStreamFactory ' ,
18- 'psr18_client ' => 'Http\Adapter\Guzzle6 \Client ' ,
18+ 'psr18_client ' => 'Http\Adapter\Guzzle7 \Client ' ,
1919 'psr17_request_factory ' => 'Nyholm\Psr7\Factory\Psr17Factory ' ,
2020 'psr17_response_factory ' => 'Nyholm\Psr7\Factory\Psr17Factory ' ,
2121 'psr17_stream_factory ' => 'Nyholm\Psr7\Factory\Psr17Factory ' ,
2525 ],
2626 'clients ' => [
2727 'test ' => [
28- 'factory ' => 'httplug.factory.guzzle6 ' ,
28+ 'factory ' => 'httplug.factory.guzzle7 ' ,
2929 'http_methods_client ' => true ,
3030 'plugins ' => [
3131 'httplug.plugin.redirect ' ,
Original file line number Diff line number Diff line change 1010 <stream-factory >my_stream_factory</stream-factory >
1111 </main-alias >
1212 <classes >
13- <client >Http\Adapter\Guzzle6 \Client</client >
13+ <client >Http\Adapter\Guzzle7 \Client</client >
1414 <message-factory >Http\Message\MessageFactory\GuzzleMessageFactory</message-factory >
1515 <uri-factory >Http\Message\UriFactory\GuzzleUriFactory</uri-factory >
1616 <stream-factory >Http\Message\StreamFactory\GuzzleStreamFactory</stream-factory >
17- <psr18-client >Http\Adapter\Guzzle6 \Client</psr18-client >
17+ <psr18-client >Http\Adapter\Guzzle7 \Client</psr18-client >
1818 <psr17-request-factory >Nyholm\Psr7\Factory\Psr17Factory</psr17-request-factory >
1919 <psr17-response-factory >Nyholm\Psr7\Factory\Psr17Factory</psr17-response-factory >
2020 <psr17-stream-factory >Nyholm\Psr7\Factory\Psr17Factory</psr17-stream-factory >
2121 <psr17-uri-factory >Nyholm\Psr7\Factory\Psr17Factory</psr17-uri-factory >
2222 <psr17-uploaded-file-factory >Nyholm\Psr7\Factory\Psr17Factory</psr17-uploaded-file-factory >
2323 <psr17-server-request-factory >Nyholm\Psr7\Factory\Psr17Factory</psr17-server-request-factory >
2424 </classes >
25- <client name =" test" factory =" httplug.factory.guzzle6 " http-methods-client =" true" >
25+ <client name =" test" factory =" httplug.factory.guzzle7 " http-methods-client =" true" >
2626 <plugin >httplug.plugin.redirect</plugin >
2727 <plugin >
2828 <add-host host =" http://localhost" />
Original file line number Diff line number Diff line change @@ -6,11 +6,11 @@ httplug:
66 uri_factory : my_uri_factory
77 stream_factory : my_stream_factory
88 classes :
9- client : Http\Adapter\Guzzle6 \Client
9+ client : Http\Adapter\Guzzle7 \Client
1010 message_factory : Http\Message\MessageFactory\GuzzleMessageFactory
1111 uri_factory : Http\Message\UriFactory\GuzzleUriFactory
1212 stream_factory : Http\Message\StreamFactory\GuzzleStreamFactory
13- psr18_client : Http\Adapter\Guzzle6 \Client
13+ psr18_client : Http\Adapter\Guzzle7 \Client
1414 psr17_request_factory : Nyholm\Psr7\Factory\Psr17Factory
1515 psr17_response_factory : Nyholm\Psr7\Factory\Psr17Factory
1616 psr17_stream_factory : Nyholm\Psr7\Factory\Psr17Factory
@@ -19,7 +19,7 @@ httplug:
1919 psr17_server_request_factory : Nyholm\Psr7\Factory\Psr17Factory
2020 clients :
2121 test :
22- factory : httplug.factory.guzzle6
22+ factory : httplug.factory.guzzle7
2323 http_methods_client : true
2424 plugins :
2525 - ' httplug.plugin.redirect'
Original file line number Diff line number Diff line change 77 async_client : auto
88 clients :
99 acme :
10- factory : httplug.factory.guzzle6
10+ factory : httplug.factory.guzzle7
1111 plugins :
1212 -
1313 decoder :
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ declare (strict_types=1 );
4+
5+ namespace Http \HttplugBundle \Tests \Unit \ClientFactory ;
6+
7+ use Http \Adapter \Guzzle7 \Client ;
8+ use Http \HttplugBundle \ClientFactory \Guzzle7Factory ;
9+ use PHPUnit \Framework \TestCase ;
10+
11+ /**
12+ * @author Tobias Nyholm <[email protected] > 13+ */
14+ class Guzzle7FactoryTest extends TestCase
15+ {
16+ public function testCreateClient (): void
17+ {
18+ if (!class_exists (Client::class)) {
19+ $ this ->markTestSkipped ('Guzzle7 adapter is not installed ' );
20+ }
21+
22+ $ factory = new Guzzle7Factory ();
23+ $ client = $ factory ->createClient ();
24+
25+ $ this ->assertInstanceOf (Client::class, $ client );
26+ }
27+ }
You can’t perform that action at this time.
0 commit comments