Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/spacetab-io/paginate-php
Simple async paginator based on Amphp.
https://github.com/spacetab-io/paginate-php
amphp async paginate paginator php php74
Last synced: 1 day ago
JSON representation
Simple async paginator based on Amphp.
- Host: GitHub
- URL: https://github.com/spacetab-io/paginate-php
- Owner: spacetab-io
- License: mit
- Created: 2020-04-06T10:49:07.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2020-04-13T13:10:44.000Z (over 4 years ago)
- Last Synced: 2024-11-14T22:36:51.555Z (6 days ago)
- Topics: amphp, async, paginate, paginator, php, php74
- Language: PHP
- Homepage:
- Size: 16.6 KB
- Stars: 2
- Watchers: 4
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
PHP Async Paginator
===================[![CircleCI](https://circleci.com/gh/spacetab-io/paginate-php/tree/master.svg?style=svg)](https://circleci.com/gh/spacetab-io/paginate-php/tree/master)
[![codecov](https://codecov.io/gh/spacetab-io/paginate-php/branch/master/graph/badge.svg)](https://codecov.io/gh/spacetab-io/paginate-php)Simple async paginator based on Amphp.
## Installation
```bash
composer require spacetab-io/paginate
```## Usage
```php
use Spacetab\Paginate\Paginator;
use Spacetab\Paginate\Adapter\SqlAdapter;
use Amp\Postgres;
use function Amp\call;call(function() {
$connection = new Postgres\ConnectionConfig('127.0.0.1');
$paginator = new Paginator(new SqlAdapter(new Postgres\Pool($connection), 'table_name'));
$paginator->setPage($query['page'] ?? null);
$paginator->setPerPage($query['per_page'] ?? null);
/** @var \Spacetab\Paginate\ResultSet $results */
$results = yield $paginator->doPaginate();$results->getItems();
$results->getCount();
$results->getPrev();
$results->getNext();
$results->getTotal();
});
````ArrayAdapter` also available.
## Depends
* \>= PHP 7.4
* Composer for install package## License
The MIT License
Copyright © 2020 spacetab.io, Inc. https://spacetab.io
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.