PHPackages                             usagi/usagi.php - 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. usagi/usagi.php

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

usagi/usagi.php
===============

Usagi's PHP library; http, couchdb

0.3.0(9y ago)018MITPHP

Since Aug 31Pushed 9y ago1 watchersCompare

[ Source](https://github.com/usagi/usagi.php)[ Packagist](https://packagist.org/packages/usagi/usagi.php)[ RSS](/packages/usagi-usagiphp/feed)WikiDiscussions master Synced 2mo ago

READMEChangelogDependenciesVersions (9)Used By (0)

Usagi's PHP library
===================

[](#usagis-php-library)

Features
========

[](#features)

0. include all features in the library
--------------------------------------

[](#0-include-all-features-in-the-library)

```
// for direct downloaded
require_once 'usagi.php/source/http.php'
// or, for composer
//require_once 'vendor/usagi/usagi.php/source/all.php'
```

note 1: this library refused to abide by PSR, thus set to 'files' mode to the composer. note 2: you can include indivisual part of this library.

1. http wrapper
---------------

[](#1-http-wrapper)

```
// for direct downloaded
require_once 'usagi.php/source/http.php'
// or, for composer
```

### 1.1. http library // stateles, simple and convinient

[](#11-http-library--stateles-simple-and-convinient)

#### GET

[](#get)

```
// a simple GET request
var_dump( \usagi\http\request( 'http://php.net' ) );
```

```
array(3) {
  ["status_code"]=>
  int(200)
  ["headers"]=>
  array(11) {
    ["Server"]=>
    string(11) "nginx/1.6.2"
    ["Date"]=>
    string(29) "Wed, 31 Aug 2016 08:27:02 GMT"
    ["Content-Type"]=>
    string(24) "text/html; charset=utf-8"
    ["Connection"]=>
    string(5) "close"
    ["X-Powered-By"]=>
    string(19) "PHP/5.6.24-0+deb8u1"
    ["Last-Modified"]=>
    string(29) "Wed, 31 Aug 2016 08:10:14 GMT"
    ["Content-language"]=>
    string(2) "en"
    ["X-Frame-Options"]=>
    string(10) "SAMEORIGIN"
    ["Set-Cookie"]=>
    string(102) "LAST_NEWS=1472632022; expires=Thu, 31-Aug-2017 08:27:02 GMT; Max-Age=31536000; path=/; domain=.php.net"
    ["Link"]=>
    string(36) "; rel=shorturl"
    ["Vary"]=>
    string(15) "Accept-Encoding"
  }
  ["content"]=>
  string(21472) "

...
}
```

#### HEAD, DELETE, ...

[](#head-delete-)

```
$response = \usagi\http\request( 'http://example.net', 'HEAD' ) );
$response = \usagi\http\request( 'http://example.net', 'DELETE' ) );
```

#### PUT, POST, ...

[](#put-post-)

```
$response = \usagi\http\request( 'http://example.net', 'PUT' , $data ) );
$response = \usagi\http\request( 'http://example.net', 'POST', $data ) );
```

#### add custom headers

[](#add-custom-headers)

```
$response = \usagi\http\request
  ( 'http://example.net'
  , 'PUT'
  , $data
  , [ 'x-my-custom-request-header-1' => 'custom value 1'
    , 'x-my-custom-request-header-2' => 'custom value 2'
    ]
  );
```

#### with convinient stateless helpers

[](#with-convinient-stateless-helpers)

```
echo \usagi\http\make_url( 'http', 'example.net', '12345' );
```

>

```
echo \usagi\http\make_url
  ( 'http'
  , 'example.net'
  , '12345'
  , [ 'path1', 'path2', 'path3   ' ]
  );
```

>

```
echo \usagi\http\make_url
  ( 'http'
  , 'example.net'
  , '12345'
  , [ 'path1', 'path2', 'path3   ' ]
  , [ 'q1_key' => 'q1_value', 'q2_key' => 'q2_value' ]
  );
```

> [http://example.net:12345/path1/path2/path3%20%20%20?q1\_key=q1\_value&amp;q2\_key=q2\_value](http://example.net:12345/path1/path2/path3%20%20%20?q1_key=q1_value&q2_key=q2_value)

and etc.

2. CouchDB library
------------------

[](#2-couchdb-library)

```
require_once 'usagi.php/source/couchdb.php'
// or, for composer
//require_once 'vendor/usagi/usagi.php/source/couchdb.php'
```

### 2.1. stateless library // for a simple usecases

[](#21-stateless-library--for-a-simple-usecases)

```
require_once 'usagi.php/source/couchdb/stateless.php'
```

#### get version infos

[](#get-version-infos)

```
var_dump( \usagi\couchdb\get_version( 'http', '127.0.0.1', 5984 ) );
```

```
array(4) {
  ["couchdb"]=>
  string(7) "Welcome"
  ["uuid"]=>
  string(32) "4fa79ddb179218126c1245256d74878f"
  ["version"]=>
  string(5) "1.6.1"
  ["vendor"]=>
  array(2) {
    ["version"]=>
    string(5) "16.04"
    ["name"]=>
    string(6) "Ubuntu"
  }
}
```

#### database features

[](#database-features)

```
$is_exists = \usagi\couchdb\is_exists_database( 'http', '127.0.0.1', 5984, 'test' );
$is_succeeded = \usagi\couchdb\create_database( 'http', '127.0.0.1', 5984, 'test' );
$is_succeeded = \usagi\couchdb\delete_database( 'http', '127.0.0.1', 5984, 'test' );
```

#### document features

[](#document-features)

```
// rev or FALSE
$rev = \usagi\couchdb\is_exists_document( 'http', '127.0.0.1', 5984, 'test', 'd1' );

// get data with decoded to a PHP array from a JSON result
$php_array_data = usagi\couchdb\get_document( 'http', '127.0.0.1', 5984, 'test2', 'd1' ) );

// create document
$id_and_rev = \usagi\couchdb\create_document( 'http', '127.0.0.1', 5984, 'test2', 'd1', $omissible_your_php_array_data );

// delete document
$is_succeeded = \usagi\couchdb\delete_document( 'http', '127.0.0.1', 5984, 'test2', 'd1' );

// update document
$id_and_rev = \usagi\couchdb\update_document( 'http', '127.0.0.1', 5984, 'test2', 'd1', [ 'hoge' => 'fuga' ] );
```

##### document attachment features

[](#document-attachment-features)

```
// attach
$is_succeeded = \usagi\couchdb\attach_document( 'http', '127.0.0.1', 5984, 'test2', 'd1', 'somthing.png' );

// detach
$is_succeeded = \usagi\couchdb\detach_document( 'http', '127.0.0.1', 5984, 'test2', 'd1', 'something.png' ) );

// attachment header infos with rev included or FALSE
$rev_and_header_infos = \usagi\couchdb\is_exists_attachment( 'http', '127.0.0.1', 5984, 'test2', 'd1', 'something.png' ) );

// get attachment binary
file_put_contents( 'somthing.png', \usagi\couchdb\get_attachment( 'http', '127.0.0.1', 5984, 'test2', 'd1', 'something.png' ), LOCK_EX );
```

### 2.2. statefull library // function chain, auto memorize parameters, auto result queueing

[](#22-statefull-library--function-chain-auto-memorize-parameters-auto-result-queueing)

```
require_once 'usagi.php/source/couchdb/statefull.php'
// or, for composer
//require_once 'vendor/usagi/usagi.php/source/couchdb/statefull.php'
```

```
$c1 = new \usagi\couchdb\statefull;

// save parameters implicit
// and functions are chainable
// and results are auto stacked/queued and exportable anythime!

$c1 -> set_auto_memorize_parameters( true ) // enabling auto memorize parameters, default is true
    -> get_document( 'document1', 'database1', 5984, '127.0.0.1', 'http' ) // queue result to results[ 0 ]
    -> shift_result( $x ) // move results[ 0 ] to $x ( remove results[ 0 ] and data be set to $x )
    -> get_document( 'document2' ) // result[ 0 ]
    -> get_attachment( 'attachemnet2-1.png' ) // result[ 1 ]
    -> get_document( $x['foobar'] ) // result[ 2 ]
    -> peek_result( 0, $y ) // copy result[ 0 ] to $y ( result[ 0 ] be not delete )
    -> get_document( $x['foobar'], 'databse2' ) // result[ 3 ]
    -> get_document( $x['foobar'], 'databse3' ) // result[ 4 ]
    -> get_document( $x['foobar'], 'databse4' ) // result[ 5 ]
    ;

// this will be out 5 results
var_dump( $c->results )
```

License
=======

[](#license)

[MIT](LICENSE)

Author
======

[](#author)

Usagi Ito

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity58

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% 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 ~1 days

Total

8

Last Release

3531d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/d0978aa8d92800b39c2144ba6e817b727ad8db78d220f48372326f730496d765?d=identicon)[usagi](/maintainers/usagi)

---

Top Contributors

[![usagi](https://avatars.githubusercontent.com/u/115972?v=4)](https://github.com/usagi "usagi (23 commits)")

---

Tags

httpcouchdbusagi

### Embed Badge

![Health badge](/badges/usagi-usagiphp/health.svg)

```
[![Health](https://phpackages.com/badges/usagi-usagiphp/health.svg)](https://phpackages.com/packages/usagi-usagiphp)
```

###  Alternatives

[guzzlehttp/psr7

PSR-7 message implementation that also provides common utility methods

8.0k1.0B3.2k](/packages/guzzlehttp-psr7)[psr/http-message

Common interface for HTTP messages

7.1k1.0B5.5k](/packages/psr-http-message)[psr/http-factory

PSR-17: Common interfaces for PSR-7 HTTP message factories

1.9k692.9M1.9k](/packages/psr-http-factory)[php-http/httplug

HTTPlug, the HTTP client abstraction for PHP

2.6k307.6M679](/packages/php-http-httplug)[psr/http-client

Common interface for HTTP clients

1.7k680.7M2.1k](/packages/psr-http-client)[symfony/http-client

Provides powerful methods to fetch HTTP resources synchronously or asynchronously

2.0k314.0M3.4k](/packages/symfony-http-client)

PHPackages © 2026

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