Giter VIP home page Giter VIP logo

proxyman's Introduction

ProxyMan

Total Downloads GitHub Version Last Commit PHP Req License

ProxyMan is OpenSource library for PHP, that makes work with proxies easy!

It providing useful proxy manager, that contains any count of proxies, makes automatic connection test and provides easy to use proxy server information


Navigation


Requirements

This library is supported by PHP versions 5.4 or higher.

Installation

The preferred way to install this extension is through Composer.

To install PHP ErrorHandler library, simply:

$ composer require tregor/proxyman

You can also clone the complete repository with Git:

$ git clone https://github.com/tregor/proxyman.git

Quick Start and Usage

You can see more in example.php file.

<?php
use tregor\ProxyMan\Exception\ProxyException;
use tregor\ProxyMan\ProxyManager;

//Adding proxy to manager
ProxyManager::addProxyHTTP("127.0.0.1", "3128");

//Simple Curl request with proxy
$ch = curl_init("https://www.google.com");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);

try{
    //Getting random proxy from Manager
    $proxy = ProxyManager::getRandomProxy();
}catch (ProxyException $e){
	echo "Error occurred: ".$e->getMessage();
}

//Setting Curl proxy type by Proxy method
curl_setopt($ch, CURLOPT_PROXYTYPE, $proxy->getType());

//Setting Curl proxy host and port string by Proxy method
curl_setopt($ch, CURLOPT_PROXY, $proxy->getHostPort());

if ($proxy->hasAuth()){
	curl_setopt($ch, CURLOPT_PROXYAUTH, CURLAUTH_BASIC);
	
	//Setting Curl proxy username and password string by Proxy method
	curl_setopt($ch, CURLOPT_PROXYUSERPWD, $proxy->getUserPass());
}

$response = curl_exec($ch);
curl_close($ch);

echo "<pre>".$response."</pre>";

Available Methods

Available methods in this library:

- Adding proxy:

This will add proxy to your proxy list. You must to chose method that coresponds your proxy type (HTTP, HTTPS, SOCKS4, SOCKS5).

ProxyManager::addProxyHTTP(string $host, string $port, string $username = "", string $password = "");
ProxyManager::addProxyHTTPS(string $host, string $port, string $username = "", string $password = "");
ProxyManager::addProxySOCKS4(string $host, string $port, string $username = "", string $password = "");
ProxyManager::addProxySOCKS5(string $host, string $port, string $username = "", string $password = "");

- Get random proxy

This will return one of your proxies, after it automatic test.

ProxyManager::getRandomProxy();

- Get all available proxies

This will return array of your proxies, that is current available.

ProxyManager::getAllProxies();

- Check proxy is alive

This will try to connect to provided URL through your proxy.

$proxy->checkConnection(string $url = "https://www.google.com/", string $method = "GET", int $timeout = 1);

- Get proxy information

This will return array with proxy info. Array contains: proxy type, host, port, username, password, ping in ms (if connection through proxy was tested).

$proxy->getInfo();

- Proxy auth

This will return boolean TRUE if proxy server needs auth or FALSE if doesn't.

$proxy->hasAuth();

TODO

  • Make tests.
  • Improve documentation.
  • Refactor code.
  • Make it better.
  • Take a cup of coffee.

Contribute

If you would like to help, please take a look at the list of issues or the ToDo checklist.

Pull requests

License

This project is licensed under MIT license. See the LICENSE file for more info.

Copyright

By tregor 2020

Please let me know, if you have feedback or suggestions.

You can contact me on Facebook or through my email.

proxyman's People

Contributors

tregor avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.