https://github.com/lctrs/circular-buffer
A circular buffer implementation in PHP
https://github.com/lctrs/circular-buffer
buffer circular cyclic php queue ring
Last synced: 9 months ago
JSON representation
A circular buffer implementation in PHP
- Host: GitHub
- URL: https://github.com/lctrs/circular-buffer
- Owner: Lctrs
- License: mit
- Created: 2021-10-16T12:05:55.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2025-08-31T09:57:23.000Z (10 months ago)
- Last Synced: 2025-09-06T22:09:18.543Z (10 months ago)
- Topics: buffer, circular, cyclic, php, queue, ring
- Language: PHP
- Size: 426 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 9
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: .github/CONTRIBUTING.md
- License: LICENSE.md
- Codeowners: .github/CODEOWNERS
Awesome Lists containing this project
README
# Circular Buffer
[](https://github.com/Lctrs/circular-buffer/actions)
[](https://github.com/Lctrs/circular-buffer/actions)
[](https://github.com/Lctrs/circular-buffer/actions)
[](https://dashboard.stryker-mutator.io/reports/github.com/Lctrs/circular-buffer/master)
[](https://codecov.io/gh/Lctrs/circular-buffer)
[](https://shepherd.dev/github/Lctrs/circular-buffer)
[](https://packagist.org/packages/Lctrs/circular-buffer)
[](https://packagist.org/packages/Lctrs/circular-buffer)
## Installation
:bulb: This is a great place for showing how to install the package, see below:
Run
```sh
$ composer require lctrs/circular-buffer
```
## Usage
Creating an empty circular buffer of size eg. 2:
```php
use Lctrs\CircularBuffer\CircularBuffer;
$buffer = CircularBuffer::ofCapacity(2);
$buffer->write('foo');
$buffer->read(); // foo
```
You can also create a prefilled buffer:
```php
use Lctrs\CircularBuffer\CircularBuffer;
$buffer = CircularBuffer::prefilled(2, ['foo', 'bar']);
```
## Changelog
Please have a look at [`CHANGELOG.md`](CHANGELOG.md).
## Contributing
Please have a look at [`CONTRIBUTING.md`](.github/CONTRIBUTING.md).
## License
This package is licensed using the MIT License.
Please have a look at [`LICENSE.md`](LICENSE.md).