Skip to content

Illuminate manager #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Aug 3, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ cache:
- $HOME/.composer/cache

php:
- 5.4
- 5.5
- 5.6
- 7.0
Expand All @@ -21,11 +20,6 @@ branches:
except:
- /^analysis-.*$/

matrix:
fast_finish: true
include:
- php: 5.4
env: COMPOSER_FLAGS="--prefer-stable --prefer-lowest" COVERAGE=true TEST_COMMAND="composer test-ci"

before_install:
- travis_retry composer self-update
Expand Down
63 changes: 63 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,72 @@ Via Composer
$ composer require php-http/laravel-httplug
```

Add serviceprovider and alias
```php
<?php
// config.app

'providers' => [
...,
...,

Http\Httplug\HttplugServiceProvider::class,

],

'aliases' => [
...,
...,

'Httplug' => Http\Httplug\Facade\Httplug::class,

],


```

Publish the package config file to config/httplug.php:

```
php artisan vendor:publish --provider="Http\Httplug\HttplugServiceProvider"
```
## Usage

```php
<?php

use GuzzleHttp\Psr7\Request;

/**
* Using the factory
*/
$factory = app()->make('httplug.message_factory.default');
$request = $factory->createRequest('GET', 'http://httpbin.org');

$httplug = app()->make('httplug');
$request = new Request('GET', 'http://httpbin.org');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's use the configured factory:

$factory = app()->make('httplug.message_factory.default');
$request = $factory->createRequest('GET', 'http://httpbin.org');


/**
* Send request with default driver
* @var \Psr\Http\Message\ResponseInterface
*/
$response = $httplug->sendRequest($request);
/**
* Send request with another driver
*/
$response = $httplug->driver('curl')->sendRequest($request);

/**
* Send request with default driver using facade
* @var \Psr\Http\Message\ResponseInterface
*/
$response = Httplug::sendRequest($request);
/**
* Send request with another driver using facade
*/
$response = Httplug::driver('curl')->sendRequest($request)

```

## Testing

Expand Down
29 changes: 16 additions & 13 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "php-http/laravel-httplug",
"description": "Laravel package to integrate the Httplug generic HTTP client into Laravel",
"keywords": ["http", "discovery", "adapter", "message", "factory", "bundle", "httplug", "php-http", "psr-7", "laravel"],
"keywords": ["http", "discovery", "adapter", "message", "factory", "httplug", "php-http", "psr-7", "laravel"],
"homepage": "http://php-http.org",
"license": "MIT",
"authors": [
Expand All @@ -11,33 +11,36 @@
}
],
"require": {
"php": ">=5.4",
"php": "^5.5 || ^7.0",
"illuminate/support": "~5",
"php-http/client-common": "^1.1",
"php-http/message-factory": "^1.0",
"php-http/message": "^1.3",
"php-http/client-common": "^1.2",
"php-http/cache-plugin": "^1.0",
"php-http/logger-plugin": "^1.0"
},
"require-dev": {
"phpunit/phpunit": "^5.1",
"phpunit/phpunit": "^4.5 || ^5.4",
"graham-campbell/testbench": "^3.1",
"friendsofphp/php-cs-fixer": "1.9.*",
"sllh/php-cs-fixer-styleci-bridge": "^1.5",
"php-http/curl-client": "^1.0",
"php-http/socket-client": "^1.0",
"php-http/guzzle6-adapter": "^1.1",
"php-http/react-adapter": "^0.1",
"php-http/buzz-adapter": "^0.1",
"php-http/message": "^1.0"
"php-http/guzzle6-adapter": "^1.1.1",
"php-http/react-adapter": "^0.2.1",
"php-http/buzz-adapter": "^0.3"
},
"prefer-stable": true,
"minimum-stability": "dev",
"autoload": {
"psr-4": {
"Http\\Httplug\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"Http\\Httplug\\": "tests/"
}
},
"scripts": {
"test": "",
"test-ci": ""
"test": "vendor/bin/phpunit",
"test-ci": "vendor/bin/phpunit --coverage-text --coverage-clover=build/coverage.xml"
}
}
84 changes: 62 additions & 22 deletions config/laravel-httplug.php
Original file line number Diff line number Diff line change
@@ -1,31 +1,71 @@
<?php



return [

'main_alias' => [
'client' => 'httplug.client.default',
'message_factory' => 'httplug.message_factory.default',
'uri_factory' => 'httplug.uri_factory.default',
'stream_factory' => 'httplug.stream_factory.default',
],

'classes' => [
# uses discovery if not specified
'client' => '',
'message_factory' => '',
'uri_factory' => '',
'stream_factory' => '',
],

'clients' => [
'acme' => [

'default' => 'guzzle6',


'adapters' => [

/**
* @link https://github.com/php-http/guzzle6-adapter
*/
'guzzle6' => [
'factory' => 'httplug.factory.guzzle6',
'plugins' => ['httplug.plugin.authentication.my_wsse', 'httplug.plugin.cache', 'httplug.plugin.retry'],
'plugins' => [
'httplug.plugin.authentication.my_wsse',
'httplug.plugin.cache',
'httplug.plugin.retry',

],

'config' => [
'verify' => false,
'verify' => false,
'timeout' => 2,
# more options to the guzzle 6 constructor
],
],

/**
* @link https://github.com/php-http/guzzle5-adapter
*/
'guzzle5' => [

],

/**
* @link https://github.com/php-http/curl-client
*/
'curl' => [

],

/**
* @link https://github.com/php-http/socket-client
*/
'socket' => [

],

/**
* @link https://github.com/php-http/buzz-adapter
*/
'buzz' => [
'resolver' => [
'timeout' => 5,
'verify_peer' => true,
'verify_host' => 2,
'proxy' => null,
],
],

/**
* @link https://github.com/php-http/react-adapter
*/
'react' => [

],

],

];
28 changes: 28 additions & 0 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit backupGlobals="false"
backupStaticAttributes="false"
beStrictAboutTestsThatDoNotTestAnything="true"
beStrictAboutOutputDuringTests="true"
bootstrap="vendor/autoload.php"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
failOnRisky="true"
failOnWarning="true"
processIsolation="false"
stopOnError="false"
stopOnFailure="false"
verbose="true"
>
<testsuites>
<testsuite>
<directory>./tests/</directory>
</testsuite>
</testsuites>
<filter>
<whitelist processUncoveredFilesFromWhitelist="true">
<directory suffix=".php">./src</directory>
</whitelist>
</filter>
</phpunit>
18 changes: 18 additions & 0 deletions src/Facade/Httplug.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php

namespace Http\Httplug\Facade;

use Illuminate\Support\Facades\Facade;

class Httplug extends Facade
{
/**
* Get the registered name of the component.
*
* @return string
*/
protected static function getFacadeAccessor()
{
return 'httplug';
}
}
22 changes: 0 additions & 22 deletions src/Httplug.php

This file was deleted.

19 changes: 0 additions & 19 deletions src/HttplugFacade.php

This file was deleted.

Loading