Skip to content

mrethical/http-proxies

Repository files navigation

Use http proxies within your Laravel application

Latest Version on Packagist GitHub Tests Action Status GitHub Code Style Action Status Total Downloads

This package help you set up a simple ip proxies management. It can also give you a GuzzleClient with a fresh active proxy configured.

Installation

You can install the package via composer:

composer require mrethical/http-proxies

You can publish and run the migrations with:

php artisan vendor:publish --tag="http-proxies-migrations"
php artisan migrate

You can publish the config file with:

php artisan vendor:publish --tag="http-proxies-config"

This is the contents of the published config file:

return [
    'model' => Mrethical\HttpProxies\Models\Proxy::class,
    'selenium' => [
        'url' => env('SELENIUM_URL', 'http://localhost:4444'),
        'timeouts' => [
            'connection' => env('SELENIUM_CONNECTION_TIMEOUT'),
            'request' => env('SELENIUM_REQUEST_TIMEOUT'),
            'pageload' => env('SELENIUM_PAGELOAD_TIMEOUT', 60),
            'script' => env('SELENIUM_SCRIPT_TIMEOUT', 3),
        ],
    ],
];

Usage

Add a proxy by calling the http-proxies:add command

php artisan http-proxies:add 1.2.3.4 --port=80

On your code, get a GuzzleClient with a fresh active proxy.

use Mrethical\HttpProxies\HttpProxies;

$client = app(HttpProxies::class)->createClient();

Testing

composer test

Changelog

Please see CHANGELOG for more information on what has changed recently.

Credits

License

The MIT License (MIT). Please see License File for more information.