PHPackages                             stk2k/net-driver - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [HTTP &amp; Networking](/categories/http)
4. /
5. stk2k/net-driver

ActiveLibrary[HTTP &amp; Networking](/categories/http)

stk2k/net-driver
================

PHP network access library

0.5.0(5y ago)030713MITPHPPHP &gt;=7.1CI failing

Since May 19Pushed 4y ago1 watchersCompare

[ Source](https://github.com/stk2k/net-driver)[ Packagist](https://packagist.org/packages/stk2k/net-driver)[ Docs](https://github.com/stk2k/net-driver)[ RSS](/packages/stk2k-net-driver/feed)WikiDiscussions master Synced 2mo ago

READMEChangelogDependencies (3)Versions (15)Used By (3)

NetDriver, HTTP client with plug-in system
==========================================

[](#netdriver-http-client-with-plug-in-system)

Description
-----------

[](#description)

NetDriver is a PHP library which provides sending HTTP requests.

Feature
-------

[](#feature)

- Pluggable. You can easily replace other HTTP access library if you want.
- Simple interfaces.
- Callback events. You can customize your request before it is exectuted. Also you can get detail logs in sending request.
- PSR-3 Logger acceptable.
- cURL/PHP(file\_get\_contents) net drivers are bundled.

Usage
-----

[](#usage)

1. Create net driver object(CurlNetDriver or PhpNetDriver are available).
2. Create handle from net driver object.
3. Create request object(HttpGetRequst/HttpPostRequest/JsonPostRequest are available).
4. Call sendRequest method of net driver object and receive response object.

Demo
----

[](#demo)

### Example 1: sending HTTP request by cURL

[](#example-1-sending-http-request-by-curl)

```
use Stk2k\NetDriver\Drivers\Curl\CurlNetDriver;

$driver = new CurlNetDriver();
$request = new HttpGetRequest($driver, 'http://sazysoft.com/test/');
$handle = $driver->newHandle();

try{
    $response = $driver->sendRequest($handle, $request);
    echo $response->getBody();
}
catch(NetDriverException $e)
{
    // error handling here
}
```

### Example 2: sending HTTP request by file\_get\_contents

[](#example-2-sending-http-request-by-file_get_contents)

```
use Stk2k\NetDriver\Drivers\Php\PhpNetDriver;

$driver = new PhpNetDriver();
$request = new HttpGetRequest($driver, 'http://sazysoft.com/test/');
$handle = $driver->newHandle();

try{
    $response = $driver->sendRequest($handle, $request);
    echo $response->getBody();
}
catch(NetDriverExceptionInterface $e)
{
    // error handling here
}
```

### Example 3: post request

[](#example-3-post-request)

```
$driver = new CurlNetDriver();
$request = new HttpPostRequest($driver, 'http://sazysoft.com/test/', ['foo' => 'bar', 'baz' => 'qux']);
$handle = $driver->newHandle();

try{
    $response = $driver->sendRequest($handle, $request);
    echo $response->getBody();
}
catch(NetDriverExceptionInterface $e)
{
    // error handling here
}
```

### Example 4: request callback

[](#example-4-request-callback)

```
$driver = new CurlNetDriver();
$request = new HttpGetRequest($driver, 'http://sazysoft.com/test/');
$handle = $driver->newHandle();

try{
    $driver->listen('request', function(HttpRequest $request){
        $request->addHttpHeader('Content-Type', 'text/json');       // set content type to text/json
        return $request;    // replace old request to new one
    });
    $response = $driver->sendRequest($handle, $request);
    echo $response->getBody();
}
catch(NetDriverExceptionInterface $e)
{
    // error handling here
}
```

### Example 5: verbose callback

[](#example-5-verbose-callback)

```
$driver = new CurlNetDriver();
$request = new HttpGetRequest($driver, 'http://sazysoft.com/test/');
$handle = $driver->newHandle();

try{
    $driver->setVerbose(true);          // curl netdriver can write debug info to output
    $driver->listen('verbose', function($strerr, $header, $output){
        echo '----[ strerr ]----' . PHP_EOL;
        echo $strerr . PHP_EOL;
        echo '----[ header ]----' . PHP_EOL;
        echo $header . PHP_EOL;
        echo '----[ output ]----' . PHP_EOL;
        echo $output . PHP_EOL;
    });
    $response = $driver->sendRequest($handle, $request);
    echo '----[ response ]----' . PHP_EOL;
    echo $response->getBody();
}
catch(NetDriverExceptionInterface $e)
{
    // error handling here
}
```

Requirement
-----------

[](#requirement)

PHP 7.1 or later

Installing NetDriver
--------------------

[](#installing-netdriver)

The recommended way to install NetDriver is through [Composer](http://getcomposer.org).

```
composer require stk2k/net-driver
```

After installing, you need to require Composer's autoloader:

```
require 'vendor/autoload.php';
```

License
-------

[](#license)

[MIT](https://github.com/stk2k/net-driver/blob/master/LICENSE)

Author
------

[](#author)

[stk2k](https://github.com/stk2k)

Disclaimer
----------

[](#disclaimer)

This software is no warranty.

We are not responsible for any results caused by the use of this software.

Please use the responsibility of the your self.

###  Health Score

28

—

LowBetter than 54% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity13

Limited adoption so far

Community15

Small or concentrated contributor base

Maturity56

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 90.9% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~80 days

Recently: every ~239 days

Total

14

Last Release

1872d ago

PHP version history (2 changes)0.1.0PHP &gt;=5.5.0

0.5.0PHP &gt;=7.1

### Community

Maintainers

![](https://www.gravatar.com/avatar/955f3d564811dc5e1212c1a7a66bc4eb7e11ac166cc38600f244dc25f97d3ef4?d=identicon)[stk2k](/maintainers/stk2k)

---

Top Contributors

[![stk2k](https://avatars.githubusercontent.com/u/985640?v=4)](https://github.com/stk2k "stk2k (20 commits)")[![sakurashiki](https://avatars.githubusercontent.com/u/10524945?v=4)](https://github.com/sakurashiki "sakurashiki (2 commits)")

---

Tags

curlhttp-clientpluggablehttpphpcurllibrarynetworknet-driver

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/stk2k-net-driver/health.svg)

```
[![Health](https://phpackages.com/badges/stk2k-net-driver/health.svg)](https://phpackages.com/packages/stk2k-net-driver)
```

###  Alternatives

[smi2/phpclickhouse

PHP ClickHouse Client

83510.1M71](/packages/smi2-phpclickhouse)[yzh52521/easyhttp

EasyHttp 是一个轻量级、语义化、对IDE友好的HTTP客户端，支持常见的HTTP请求、异步请求和并发请求，让你可以快速地使用 HTTP 请求与其他 Web 应用进行通信。

429.3k3](/packages/yzh52521-easyhttp)[popphp/pop-http

Pop Http Component for Pop PHP Framework

1018.5k13](/packages/popphp-pop-http)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
