tal7aouy/pagify
最新稳定版本:v1.0.0
Composer 安装命令:
composer require tal7aouy/pagify
包简介
A PHP library for JSON pagination with various features.
README 文档
README
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:
composer require tal7aouy/pagify
Usage
Basic Usage
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:
./pagify <currentPage> <perPage>
Example:
./pagify 2 10
Configuration
You can configure default settings in config/paginator.php:
return [ 'default_per_page' => 10, ];
Testing
Unit Tests
Run unit tests with PestPHP:
composer test
Example Test
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.
License
This project is licensed under the MIT License - see the LICENSE file for details.
Made with ❤️ by Mhammed Talhaouy
统计信息
- 总下载量: 4
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: Unknown
- 更新时间: 2024-08-20