PHPackages                             universal/universal - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. universal/universal

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

universal/universal
===================

Universal library for PHP

818.7k↓50%2[1 PRs](https://github.com/c9s/universal/pulls)6PHP

Since Sep 10Pushed 3y ago1 watchersCompare

[ Source](https://github.com/c9s/universal)[ Packagist](https://packagist.org/packages/universal/universal)[ RSS](/packages/universal-universal/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (6)

Universal
=========

[](#universal)

Universal is a general proprose PHP library.

[![Build Status](https://camo.githubusercontent.com/b6eec5bce186ab9ced496f6b3b7758cb64f7d1bdfb0b61693b96e2bb9aba8573/68747470733a2f2f7472617669732d63692e6f72672f6339732f756e6976657273616c2e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/c9s/universal)[![Coverage Status](https://camo.githubusercontent.com/0389be866c96f75196fb991eaad8b239715160f1bd5e231e6fcf5016a62793bd/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6769746875622f6339732f756e6976657273616c2f62616467652e7376673f6272616e63683d6d6173746572)](https://coveralls.io/github/c9s/universal?branch=master)

Install
=======

[](#install)

```
composer require universal/universal 2.0.x-dev
```

Components
==========

[](#components)

- ClassLoaders
- Container
- HTTPRequest

Classloader
-----------

[](#classloader)

### BasePathClassLoader

[](#basepathclassloader)

```
$loader = new BasePathClassLoader( array(
    'vendor/pear', 'external_vendor/src'
) );
$loader->useEnvPhpLib();
$loader->register();
```

### Include Path Manipulator

[](#include-path-manipulator)

Include Path manipulator

```
$includer = new PathIncluder(array( 'to/path', ... ));
$includer->add( 'path/to/lib' );
$includer->setup();   // write set_include_path
```

Http
----

[](#http)

### StreamResponse

[](#streamresponse)

MXHR support

```
$response = new Universal\Http\StreamResponse;
for( $i = 0 ; $i < 30000 ; $i++ ) {
    $response->write(json_encode(array('i' => $i)), array(
        'Content-Type' => 'application/json',
    ));
    usleep(200000);
}
$response->finish();
```

### HttpRequest

[](#httprequest)

For multiple files:

```
