Skip to content

Commit a8637d9

Browse files
committed
Init package
1 parent 9ed5d39 commit a8637d9

File tree

5 files changed

+68
-21
lines changed

5 files changed

+68
-21
lines changed

composer.json

Lines changed: 13 additions & 4 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", "laravel"],
4+
"keywords": ["http", "discovery", "adapter", "message", "factory", "bundle", "httplug", "php-http", "psr-7", "laravel"],
55
"homepage": "http://php-http.org",
66
"license": "MIT",
77
"authors": [
@@ -13,12 +13,21 @@
1313
"require": {
1414
"php": ">=5.4",
1515
"illuminate/support": "~5",
16-
"php-http/httplug": "1.*"
16+
"php-http/client-common": "^1.1",
17+
"php-http/message-factory": "^1.0",
18+
"php-http/cache-plugin": "^1.0",
19+
"php-http/logger-plugin": "^1.0"
1720
},
1821
"require-dev": {
1922
"phpunit/phpunit": "^5.1",
20-
"fabpot/php-cs-fixer": "^1.11",
21-
"sllh/php-cs-fixer-styleci-bridge": "^1.5"
23+
"friendsofphp/php-cs-fixer": "1.9.*",
24+
"sllh/php-cs-fixer-styleci-bridge": "^1.5",
25+
"php-http/curl-client": "^1.0",
26+
"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"
2231
},
2332
"prefer-stable": true,
2433
"minimum-stability": "dev",

config/laravel-httplug.php

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,30 @@
22

33
return [
44

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' => [
22+
'factory' => 'httplug.factory.guzzle6',
23+
'plugins' => ['httplug.plugin.authentication.my_wsse', 'httplug.plugin.cache', 'httplug.plugin.retry'],
24+
'config' => [
25+
'verify' => false,
26+
'timeout' => 2,
27+
# more options to the guzzle 6 constructor
28+
],
29+
],
30+
],
531
];

src/Httplug.php

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,17 @@
66
* (c) laravel-httplug <mathieu.santostefano@gmail.com>
77
*/
88

9-
namespace Http\Httplug;
9+
namespace Http\LaravelHttplug;
10+
11+
use Http\Client\HttpClient;
1012

1113
class Httplug
1214
{
13-
public static function hello()
15+
/** @var HttpClient */
16+
private $client;
17+
18+
public function __construct()
1419
{
15-
return 'hello';
20+
$this->client = '';
1621
}
1722
}

src/HttplugFacade.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@
66
* (c) laravel-httplug <mathieu.santostefano@gmail.com>
77
*/
88

9-
namespace Http\Httplug;
9+
namespace Http\LaravelHttplug;
1010

1111
use Illuminate\Support\Facades\Facade;
1212

1313
class HttplugFacade extends Facade
1414
{
1515
protected static function getFacadeAccessor()
1616
{
17-
return 'http-httplug';
17+
return 'laravel-httplug';
1818
}
1919
}

src/HttplugServiceProvider.php

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@
66
* (c) laravel-httplug <mathieu.santostefano@gmail.com>
77
*/
88

9-
namespace Http\Httplug;
9+
namespace Http\LaravelHttplug;
1010

1111
use Illuminate\Support\ServiceProvider;
1212

1313
class HttplugServiceProvider extends ServiceProvider
1414
{
1515
/**
16-
* Bootstrap the application events.
16+
* Bootstrap the application services.
1717
*/
1818
public function boot()
1919
{
@@ -23,22 +23,29 @@ public function boot()
2323
}
2424

2525
/**
26-
* Register the service provider.
26+
* Register the application services.
2727
*/
2828
public function register()
2929
{
3030
$this->mergeConfigFrom(__DIR__.'/../config/laravel-httplug.php', 'laravel-httplug');
31-
32-
$this->app->bind('http-httplug', function () {
31+
$this->app->bind(Httplug::class, function () {
3332
return new Httplug();
3433
});
35-
}
3634

37-
/**
38-
* Get the services provided by the provider.
39-
*/
40-
public function provides()
41-
{
42-
return ['laravel-http-httplug'];
35+
$config = config('laravel-httplug');
36+
37+
foreach ($config['classes'] as $service => $class) {
38+
if (!empty($class)) {
39+
$this->app->register(sprintf('httplug.%s.default', $service), function() use($class) {
40+
return new $class();
41+
});
42+
}
43+
}
44+
45+
foreach ($config['main_alias'] as $type => $id) {
46+
$this->app->alias(sprintf('httplug.%s', $type), $id);
47+
}
48+
49+
$this->app->alias(Httplug::class, 'laravel-httplug');
4350
}
4451
}

0 commit comments

Comments
 (0)