cacahouwete/lazy-api-collection 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

cacahouwete/lazy-api-collection

最新稳定版本:v0.1.0

Composer 安装命令:

composer require cacahouwete/lazy-api-collection

包简介

Handle rest api endpoint with pagination through an unique iterable

README 文档

README

PHP tool to have an easy way to iterate an api with multiple pages

Installation with symfony

composer require cacahouwete/lazy-api-collection 

Add bundle in your symfony project

<?php
// config/bundles.php

return [
    ...
    LazyApiCollection\Bridge\Symfony\LazyApiCollectionBundle::class => ['all' => true],
]

Basic usage with symfony

<?php
namespace App\ApiEntity;

// src/ApiEntity/Dummy.php
final class Dummy {
    public string $field1;
    public string $field2;
    ....
}
// src/ApiRepository/DummyApiRepository.php
namespace App\ApiRepository;

use LazyApiCollection\Bridge\Symfony\Builder\LazyApiCollectionBuilderInterface;
use LazyApiCollection\Model\ApiCollection;
use LazyApiCollection\Model\LazyApiCollection;

final class DummyApiRepository
{
    private const PATH = '/api/dummies';
    
    private LazyApiCollectionBuilderInterface $lazyApiCollectionBuilder;
    private string $targetUrl;

    public function __construct(LazyApiCollectionBuilderInterface $lazyApiCollectionBuilder, string $targetUrl)
    {
        $this->lazyApiCollectionBuilder = $lazyApiCollectionBuilder;
        $this->targetUrl = $targetUrl;
    }

    /**
     * @return iterable<Dummy>
     */
    public function findAllByPageAndNbItem(): iterable
    {
        return $this->lazyApiCollectionBuilder
            ->create($this->targetUrl.self::PATH, Dummy::class)
            ->build()
        ;
    }
}

统计信息

  • 总下载量: 3.28k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2022-11-09