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

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

php-comp/shm
============

shared memory library of the php

v1.1.2(7y ago)6361[1 issues](https://github.com/phppkg/shared-memory/issues)MITPHPPHP &gt;7.0.0

Since Mar 2Pushed 7y ago1 watchersCompare

[ Source](https://github.com/phppkg/shared-memory)[ Packagist](https://packagist.org/packages/php-comp/shm)[ Docs](https://github.com/php-comp/shared-memory)[ RSS](/packages/php-comp-shm/feed)WikiDiscussions master Synced 3d ago

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

php 共享内存
========

[](#php-共享内存)

[![License](https://camo.githubusercontent.com/b66fc2e1c0b6186502fdedf27620c52976389b0ec091b0ca2386a2918f846bac/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f7068702d636f6d702f73686d2e7376673f7374796c653d666c61742d737175617265)](LICENSE)[![Php Version](https://camo.githubusercontent.com/5127919eba34cfd4efa2e1d76a62f25de4061ec0a31a434fd9b23f6b16fc2c0e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d2533453d372e302d627269676874677265656e2e7376673f6d61784167653d32353932303030)](https://packagist.org/packages/php-comp/shm)[![Latest Stable Version](https://camo.githubusercontent.com/63e232f4846d47bf475a247795a5aadc941ed80521b8ebfe4e129d2b1c6a9f87/687474703a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f7068702d636f6d702f73686d2e737667)](https://packagist.org/packages/php-comp/shm)

php 共享内存操作的实现。基于

- sysvshm扩展：实现system v方式的共享内存 `linux/mac`
- shmop扩展：共享内存操作扩展 `linux/mac/windows`

功能：

- 实现了共享内存的 `写入` `读取` `删除` `释放` 基本操作
- 扩展的类 `ShmMap` 实现了基于共享内存的数组结构(数组方式操作、pop/push、迭代器,读/取都会自动加锁)。

安装
--

[](#安装)

- composer

```
{
    "require": {
        "php-comp/shm": "dev-master"
    }
}
```

- 直接拉取

```
git clone https://github.com/php-comp/shared-memory.git // github
```

使用
--

[](#使用)

```
use PhpComp\Shm\ShmFactory;
use PhpComp\Shm\ShmMap;

$shm = ShmFactory::make([
    'key' => 1,
    'size' => 512
]);

$shm->write('data string');
$ret = $shm->read();

var_dump($ret);

$shmAry = new ShmMap([
    'key' => 2,
    'size' => 512
]);

$shmAry['one'] = 'val1';
$shmAry['two'] = 'val2';
$shmAry->set('three', 'val3');

var_dump($shmAry['three'], $shmAry->getMap());

unset($shmAry['two']);

var_dump($shmAry->getMap());
```

License
-------

[](#license)

[MIT](LICENSE)

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance17

Infrequent updates — may be unmaintained

Popularity13

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity60

Established project with proven stability

 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 ~132 days

Total

3

Last Release

2730d ago

### 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 (14 commits)")

---

Tags

php-libraryshared-memoryphplibraryshared memory

### Embed Badge

![Health badge](/badges/php-comp-shm/health.svg)

```
[![Health](https://phpackages.com/badges/php-comp-shm/health.svg)](https://phpackages.com/packages/php-comp-shm)
```

PHPackages © 2026

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