https://github.com/mazesec/pagify
Pagify is a modern PHP library for handling JSON pagination efficiently
https://github.com/mazesec/pagify
json-paginator pagination
Last synced: 10 months ago
JSON representation
Pagify is a modern PHP library for handling JSON pagination efficiently
- Host: GitHub
- URL: https://github.com/mazesec/pagify
- Owner: mazesec
- License: mit
- Created: 2024-08-20T11:30:08.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2024-08-20T11:31:02.000Z (almost 2 years ago)
- Last Synced: 2025-07-22T12:27:15.358Z (11 months ago)
- Topics: json-paginator, pagination
- Language: PHP
- Homepage:
- Size: 6.84 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE.md
Awesome Lists containing this project
README
# Pagify




**Pagify** is a modern PHP library for handling JSON pagination efficiently. Designed to be simple yet powerful, this library helps you paginate data seamlessly for APIs and web applications.
## Features
- **Easy Integration**: Simple to use with minimal setup.
- **Flexible Configuration**: Customize page size and pagination behavior.
- **Error Handling**: Graceful handling of invalid parameters.
- **CLI Tool**: Command-line utility for quick testing and usage.
- **Logging**: Built-in logging for debugging and monitoring.
## Installation
You can install Pagify using Composer:
```bash
composer require tal7aouy/pagify
```
## Usage
### Basic Usage
```php
use Tal7aouy\Pagify\JsonPaginator;
use Tal7aouy\Pagify\PaginatorFactory;
$items = range(1, 100); // Example data
$totalItems = count($items);
$paginator = PaginatorFactory::createPaginator($items, $totalItems, 1, 10);
echo $paginator->toJson();
```
### CLI Tool
To use the CLI tool, run:
```bash
./pagify
```
Example:
```bash
./pagify 2 10
```
## Configuration
You can configure default settings in `config/paginator.php`:
```php
return [
'default_per_page' => 10,
];
```
## Testing
### Unit Tests
Run unit tests with PestPHP:
```bash
composer test
```
### Example Test
```php
it('paginates data correctly', function () {
// Test code here...
});
```
## Contributing
Contributions are welcome! Please open an issue or submit a pull request. For more details, see [CONTRIBUTING.md](CONTRIBUTING.md).
## License
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
---
Made with ❤️ by [Mhammed Talhaouy](https://github.com/tal7aouy)