peterfox / runscope
This package makes using Runscope in applications easy, including Guzzle and GuzzleHttp plugin
Installs: 1 294
Dependents: 0
Suggesters: 0
Security: 0
Stars: 5
Watchers: 1
Forks: 5
Open Issues: 1
Requires
- php: >=5.3.0
- psr/log: 1.0.0
Requires (Dev)
- guzzle/guzzle: ~3.8
- guzzlehttp/guzzle: ~4.0
- illuminate/support: ~4.1
- monolog/monolog: 1.6.*
- phpspec/phpspec: 2.0.*@dev
- raulfraile/ladybug: ~1.0
Suggests
- guzzle/guzzle: ~3.8
- guzzlehttp/guzzle: ~4.0
- illuminate/support: ~4.1
This package is not auto-updated.
Last update: 2021-10-16 01:05:26 UTC
README
- Requires a free Runscope account, sign up here
- Makes it easy to generate Runescope urls
- Provides plugins for both Guzzle (3.0) and GuzzleHttp (4.0)
- Has dependancy injection support for Laravel 4, through included ServiceProvider and Facade classes
Install by issuing:
composer require peterfox/runscope
The most basic usage is as follows:
<?php require __DIR__ . '/../vendor/autoload.php'; use Runscope\Runscope; $runscope = new Runscope('api-key-here'); $runscopeUrl = $runscope->proxify('https://api.github.com');
Please note, generating these urls will always provide a url that works on port 80/443 for http/https respectively as using ports other than the standard ones for a protocol requires headers.
Using with Guzzle/GuzzleHttp
applying the plugin is like so for Guzzle:
<?php require __DIR__ . '/../vendor/autoload.php'; use Runscope\Runscope; use Guzzle\Http\Client; use Runscope\Plugin\Guzzle\RunscopePlugin; $runscope = new Runscope('api-key-here'); $client = new Client('https://api.github.com'); $runscopePlugin = new RunscopePlugin($runscope); // Add the plugin $client->addSubscriber($runscopePlugin); // Send the request and get the response $response = $client->get('/')->send();
Using the GuzzleHttp Plugin can be done with:
<?php require __DIR__ . '/../vendor/autoload.php'; use Runscope\Runscope; use GuzzleHttp\Client; use Runscope\Plugin\GuzzleHttp\RunscopePlugin; $runscope = new Runscope('api-key-here'); $client = new Client('https://api.github.com'); $runscopePlugin = new RunscopePlugin($runscope); // Attach the plugin $client->getEmitter()->attach($runscopePlugin); // Send the request and get the response $response = $client->get('/');
Laravel 4 Integration
Add the service provider:
'providers' => array( ... 'Runscope\RunscopeServiceProvider' )
You can then publish the config file from the package:
php artisan config:publish peterfox/runscope
The blank config will at a minimum require your bucket key (ID):
<?php return array( 'bucket_key' => '', 'auth_token' => null, 'gateway_host' => 'runscope.net' );
With the service provider in place it will also set up the Facade for you so you can use:
$url = Runscope::proxify('https://api.github.com');
You'll also have a helper function which makes things a little lighter
$url = runscope_url('https://api.github.com');