Skip to content

Commit 1039f27

Browse files
dlnilssonNyholm
authored andcommitted
Illuminate manager (#1)
* introduces manager * Updated README * bumped versions * added container injection tests * updated example * added phpunit.xml * remove support for php 5.4
1 parent a8637d9 commit 1039f27

13 files changed

+506
-107
lines changed

.travis.yml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ cache:
77
- $HOME/.composer/cache
88

99
php:
10-
- 5.4
1110
- 5.5
1211
- 5.6
1312
- 7.0
@@ -21,11 +20,6 @@ branches:
2120
except:
2221
- /^analysis-.*$/
2322

24-
matrix:
25-
fast_finish: true
26-
include:
27-
- php: 5.4
28-
env: COMPOSER_FLAGS="--prefer-stable --prefer-lowest" COVERAGE=true TEST_COMMAND="composer test-ci"
2923

3024
before_install:
3125
- travis_retry composer self-update

README.md

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,72 @@ Via Composer
1515
$ composer require php-http/laravel-httplug
1616
```
1717

18+
Add serviceprovider and alias
19+
```php
20+
<?php
21+
// config.app
1822

23+
'providers' => [
24+
...,
25+
...,
26+
27+
Http\Httplug\HttplugServiceProvider::class,
28+
29+
],
30+
31+
'aliases' => [
32+
...,
33+
...,
34+
35+
'Httplug' => Http\Httplug\Facade\Httplug::class,
36+
37+
],
38+
39+
40+
```
41+
42+
Publish the package config file to config/httplug.php:
43+
44+
```
45+
php artisan vendor:publish --provider="Http\Httplug\HttplugServiceProvider"
46+
```
1947
## Usage
2048

49+
```php
50+
<?php
51+
52+
use GuzzleHttp\Psr7\Request;
53+
54+
/**
55+
* Using the factory
56+
*/
57+
$factory = app()->make('httplug.message_factory.default');
58+
$request = $factory->createRequest('GET', 'http://httpbin.org');
59+
60+
$httplug = app()->make('httplug');
61+
$request = new Request('GET', 'http://httpbin.org');
62+
63+
/**
64+
* Send request with default driver
65+
* @var \Psr\Http\Message\ResponseInterface
66+
*/
67+
$response = $httplug->sendRequest($request);
68+
/**
69+
* Send request with another driver
70+
*/
71+
$response = $httplug->driver('curl')->sendRequest($request);
72+
73+
/**
74+
* Send request with default driver using facade
75+
* @var \Psr\Http\Message\ResponseInterface
76+
*/
77+
$response = Httplug::sendRequest($request);
78+
/**
79+
* Send request with another driver using facade
80+
*/
81+
$response = Httplug::driver('curl')->sendRequest($request)
82+
83+
```
2184

2285
## Testing
2386

composer.json

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "php-http/laravel-httplug",
33
"description": "Laravel package to integrate the Httplug generic HTTP client into Laravel",
4-
"keywords": ["http", "discovery", "adapter", "message", "factory", "bundle", "httplug", "php-http", "psr-7", "laravel"],
4+
"keywords": ["http", "discovery", "adapter", "message", "factory", "httplug", "php-http", "psr-7", "laravel"],
55
"homepage": "http://php-http.org",
66
"license": "MIT",
77
"authors": [
@@ -11,33 +11,36 @@
1111
}
1212
],
1313
"require": {
14-
"php": ">=5.4",
14+
"php": "^5.5 || ^7.0",
1515
"illuminate/support": "~5",
16-
"php-http/client-common": "^1.1",
17-
"php-http/message-factory": "^1.0",
16+
"php-http/message": "^1.3",
17+
"php-http/client-common": "^1.2",
1818
"php-http/cache-plugin": "^1.0",
1919
"php-http/logger-plugin": "^1.0"
2020
},
2121
"require-dev": {
22-
"phpunit/phpunit": "^5.1",
22+
"phpunit/phpunit": "^4.5 || ^5.4",
23+
"graham-campbell/testbench": "^3.1",
2324
"friendsofphp/php-cs-fixer": "1.9.*",
2425
"sllh/php-cs-fixer-styleci-bridge": "^1.5",
2526
"php-http/curl-client": "^1.0",
2627
"php-http/socket-client": "^1.0",
27-
"php-http/guzzle6-adapter": "^1.1",
28-
"php-http/react-adapter": "^0.1",
29-
"php-http/buzz-adapter": "^0.1",
30-
"php-http/message": "^1.0"
28+
"php-http/guzzle6-adapter": "^1.1.1",
29+
"php-http/react-adapter": "^0.2.1",
30+
"php-http/buzz-adapter": "^0.3"
3131
},
32-
"prefer-stable": true,
33-
"minimum-stability": "dev",
3432
"autoload": {
3533
"psr-4": {
3634
"Http\\Httplug\\": "src/"
3735
}
3836
},
37+
"autoload-dev": {
38+
"psr-4": {
39+
"Http\\Httplug\\": "tests/"
40+
}
41+
},
3942
"scripts": {
40-
"test": "",
41-
"test-ci": ""
43+
"test": "vendor/bin/phpunit",
44+
"test-ci": "vendor/bin/phpunit --coverage-text --coverage-clover=build/coverage.xml"
4245
}
4346
}

config/laravel-httplug.php

Lines changed: 62 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,71 @@
11
<?php
2-
2+
3+
34
return [
4-
5-
'main_alias' => [
6-
'client' => 'httplug.client.default',
7-
'message_factory' => 'httplug.message_factory.default',
8-
'uri_factory' => 'httplug.uri_factory.default',
9-
'stream_factory' => 'httplug.stream_factory.default',
10-
],
11-
12-
'classes' => [
13-
# uses discovery if not specified
14-
'client' => '',
15-
'message_factory' => '',
16-
'uri_factory' => '',
17-
'stream_factory' => '',
18-
],
19-
20-
'clients' => [
21-
'acme' => [
5+
6+
'default' => 'guzzle6',
7+
8+
9+
'adapters' => [
10+
11+
/**
12+
* @link https://github.com/php-http/guzzle6-adapter
13+
*/
14+
'guzzle6' => [
2215
'factory' => 'httplug.factory.guzzle6',
23-
'plugins' => ['httplug.plugin.authentication.my_wsse', 'httplug.plugin.cache', 'httplug.plugin.retry'],
16+
'plugins' => [
17+
'httplug.plugin.authentication.my_wsse',
18+
'httplug.plugin.cache',
19+
'httplug.plugin.retry',
20+
21+
],
22+
2423
'config' => [
25-
'verify' => false,
24+
'verify' => false,
2625
'timeout' => 2,
27-
# more options to the guzzle 6 constructor
2826
],
2927
],
28+
29+
/**
30+
* @link https://github.com/php-http/guzzle5-adapter
31+
*/
32+
'guzzle5' => [
33+
34+
],
35+
36+
/**
37+
* @link https://github.com/php-http/curl-client
38+
*/
39+
'curl' => [
40+
41+
],
42+
43+
/**
44+
* @link https://github.com/php-http/socket-client
45+
*/
46+
'socket' => [
47+
48+
],
49+
50+
/**
51+
* @link https://github.com/php-http/buzz-adapter
52+
*/
53+
'buzz' => [
54+
'resolver' => [
55+
'timeout' => 5,
56+
'verify_peer' => true,
57+
'verify_host' => 2,
58+
'proxy' => null,
59+
],
60+
],
61+
62+
/**
63+
* @link https://github.com/php-http/react-adapter
64+
*/
65+
'react' => [
66+
67+
],
68+
3069
],
70+
3171
];

phpunit.xml.dist

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<phpunit backupGlobals="false"
3+
backupStaticAttributes="false"
4+
beStrictAboutTestsThatDoNotTestAnything="true"
5+
beStrictAboutOutputDuringTests="true"
6+
bootstrap="vendor/autoload.php"
7+
colors="true"
8+
convertErrorsToExceptions="true"
9+
convertNoticesToExceptions="true"
10+
convertWarningsToExceptions="true"
11+
failOnRisky="true"
12+
failOnWarning="true"
13+
processIsolation="false"
14+
stopOnError="false"
15+
stopOnFailure="false"
16+
verbose="true"
17+
>
18+
<testsuites>
19+
<testsuite>
20+
<directory>./tests/</directory>
21+
</testsuite>
22+
</testsuites>
23+
<filter>
24+
<whitelist processUncoveredFilesFromWhitelist="true">
25+
<directory suffix=".php">./src</directory>
26+
</whitelist>
27+
</filter>
28+
</phpunit>

src/Facade/Httplug.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?php
2+
3+
namespace Http\Httplug\Facade;
4+
5+
use Illuminate\Support\Facades\Facade;
6+
7+
class Httplug extends Facade
8+
{
9+
/**
10+
* Get the registered name of the component.
11+
*
12+
* @return string
13+
*/
14+
protected static function getFacadeAccessor()
15+
{
16+
return 'httplug';
17+
}
18+
}

src/Httplug.php

Lines changed: 0 additions & 22 deletions
This file was deleted.

src/HttplugFacade.php

Lines changed: 0 additions & 19 deletions
This file was deleted.

0 commit comments

Comments
 (0)