alexandrebulete/ddd-apiplatform-bridge 问题修复 & 功能扩展

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

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

alexandrebulete/ddd-apiplatform-bridge

最新稳定版本:1.0.0

Composer 安装命令:

composer require alexandrebulete/ddd-apiplatform-bridge

包简介

API Platform bridge for DDD Foundation - Pure PHP, no framework dependency

README 文档

README

API Platform bridge for DDD Foundation. Provides State providers, processors, and pagination utilities.

Pure PHP - No framework dependency. Can be used with Symfony or Laravel (future).

Installation

composer require alexandrebulete/ddd-apiplatform-bridge

For Symfony integration, also install:

composer require alexandrebulete/ddd-apiplatform-bundle

Structure

src/
└── State/
    └── Paginator.php

Usage

Paginator

A generic paginator implementing API Platform's PaginatorInterface:

use AlexandreBulete\DddApiPlatformBridge\State\Paginator;
use AlexandreBulete\DddFoundation\Application\Query\QueryBusInterface;

class GetPostsProvider implements ProviderInterface
{
    public function __construct(
        private QueryBusInterface $queryBus,
    ) {}

    public function provide(Operation $operation, array $uriVariables = [], array $context = []): object|array|null
    {
        $repository = $this->queryBus->ask(new GetPostsQuery(
            page: $context['filters']['page'] ?? 1,
            itemsPerPage: $context['filters']['itemsPerPage'] ?? 30,
        ));

        $paginator = $repository->paginator();

        if (null === $paginator) {
            return iterator_to_array($repository);
        }

        return new Paginator(
            items: $paginator,
            currentPage: $paginator->getCurrentPage(),
            itemsPerPage: $paginator->getItemsPerPage(),
            lastPage: $paginator->getLastPage(),
            totalItems: $paginator->getTotalItems(),
        );
    }
}

Usage with API Platform Resources

use ApiPlatform\Metadata\ApiResource;
use ApiPlatform\Metadata\GetCollection;

#[ApiResource(
    operations: [
        new GetCollection(
            provider: GetPostsProvider::class,
        ),
    ],
)]
class PostResource
{
    public function __construct(
        public string $id,
        public string $title,
        public string $content,
    ) {}
}

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-01-26

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固