PHPackages                             toolkit/pool - 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. toolkit/pool

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

toolkit/pool
============

a simple resource pool library of the php

v0.1.2(7y ago)318MITPHPPHP &gt;7.1

Since Nov 26Pushed 7y ago1 watchersCompare

[ Source](https://github.com/php-toolkit/pool)[ Packagist](https://packagist.org/packages/toolkit/pool)[ Docs](http://github.com/php-toolkit/pool)[ RSS](/packages/toolkit-pool/feed)WikiDiscussions master Synced 3d ago

READMEChangelogDependencies (1)Versions (3)Used By (0)

资源池
===

[](#资源池)

[![License](https://camo.githubusercontent.com/ae5e6f8e73d90595fc9bc1be1b6ce67484106c0f863e6c7a1b325e19b890bfa9/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f746f6f6c6b69742f706f6f6c2e7376673f7374796c653d666c61742d737175617265)](LICENSE)[![Php Version](https://camo.githubusercontent.com/5127919eba34cfd4efa2e1d76a62f25de4061ec0a31a434fd9b23f6b16fc2c0e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d2533453d372e302d627269676874677265656e2e7376673f6d61784167653d32353932303030)](https://packagist.org/packages/toolkit/pool)[![Latest Stable Version](https://camo.githubusercontent.com/b0da98773d2a08c1e89be48605b847d9f352ec4c284c732512ced11108f33a9c/687474703a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f746f6f6c6b69742f706f6f6c2e737667)](https://packagist.org/packages/toolkit/pool)

> 资源池使用在 **常住进程的服务** 中才有用。比如用 swoole/workman 创建的应用

使用池可实现 数据库连接池、redis连接池等，减少对服务的过多的连接/断开带来的额外资源消耗。

- 基于swoole的实现

本仓库主要是做一些关于连接池的基础接口方法的抽象定义，并没有完整具体的实现。

> 具体的实现请查看：

项目地址
----

[](#项目地址)

- **github**

安装
--

[](#安装)

- 使用 `composer require toolkit/pool`
- 使用 `composer.json`

```
"toolkit/pool": "dev-master"

```

然后执行: `composer update`

- 直接拉取

```
git clone https://git.oschina.net/inhere/php-resource-pool.git // git@osc
git clone https://github.com/inhere/php-resource-pool.git // github

```

使用
--

[](#使用)

```
use Toolkit\Pool\Raw\ResourcePool;

$rpl = new ResourcePool([
    'initSize' => 2,
    'maxSize' => 2,
    'driverOptions' => [

    ],
]);

$rpl->setCreator(function () {
    $obj = new \stdClass();
    $obj->name = 'test';

    return $obj;
})
    ->setDestroyer(function ($obj) {
    echo "call resource destroyer.\n";
});

var_dump($rpl);

$obj1 = $rpl->get();
$obj2 = $rpl->get();
$obj3 = $rpl->get();

var_dump($obj1, $obj2, $obj3,$rpl);

$rpl->put($obj1);
$rpl->put($obj2);

var_dump($rpl);

$rpl->call(function ($obj) {
   echo " $obj->name\n";
});

var_dump($rpl);
```

License
-------

[](#license)

[MIT](LICENSE)

###  Health Score

23

—

LowBetter than 27% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity10

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity47

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

2

Last Release

2725d ago

PHP version history (2 changes)v0.1.1PHP &gt;=7.0.0

v0.1.2PHP &gt;7.1

### Community

Maintainers

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

---

Top Contributors

[![inhere](https://avatars.githubusercontent.com/u/5302062?v=4)](https://github.com/inhere "inhere (25 commits)")

---

Tags

poolresource-poollibraryresource-pool

### Embed Badge

![Health badge](/badges/toolkit-pool/health.svg)

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

###  Alternatives

[league/iso3166

ISO 3166-1 PHP Library

69536.3M116](/packages/league-iso3166)[league/statsd

A simple library for working with StatsD in PHP.

3514.3M12](/packages/league-statsd)[payum/iso4217

ISO 4217 PHP Library

16312.1M5](/packages/payum-iso4217)[lambdish/phunctional

λ PHP functional library

3612.0M23](/packages/lambdish-phunctional)[dekor/php-array-table

PHP Library for printing associative arrays as text table (similar to mysql terminal console)

296.6M2](/packages/dekor-php-array-table)

PHPackages © 2026

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