承接 aipng/apitte-mapping 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

aipng/apitte-mapping

Composer 安装命令:

composer require aipng/apitte-mapping

包简介

Custom type mappers for contributte/apitte

README 文档

README

Custom parameter type mappers for contributte/apitte.

Installation

composer require aipng/apitte-mapping

Registration

Register the mappers manually in your Nette configuration:

api:
    plugins:
        Apitte\Core\DI\Plugin\CoreMappingPlugin:
            types:
                date: AipNg\ApitteMapping\Parameter\DateTypeMapper
                email: AipNg\ApitteMapping\Parameter\EmailTypeMapper
                int_array: AipNg\ApitteMapping\Parameter\IntegerArrayTypeMapper

Mappers

DateTypeMapper

Type name: date

Accepts a date string in Y-m-d format and returns a DateTimeImmutable with time set to 00:00:00.

Invalid input throws Apitte\Core\Exception\Runtime\InvalidArgumentTypeException.

EmailTypeMapper

Type name: email

Accepts an email address string and returns an AipNg\ValueObjects\Web\Email value object. The address is normalized to lowercase.

Invalid input throws Apitte\Core\Exception\Runtime\InvalidArgumentTypeException.

IntegerArrayTypeMapper

Type name: int_array

Accepts a comma-separated string of integers (e.g. 1,2,3) and returns array<int>. Whitespace around items is trimmed. Empty string or comma-only input returns an empty array.

Invalid input (non-string, non-integer values, floats) throws Apitte\Core\Exception\Runtime\InvalidArgumentTypeException.

Usage

use Apitte\Core\Annotation\Controller\Path;
use Apitte\Core\Annotation\Controller\RequestParameter;
use Apitte\Core\Annotation\Controller\Method;
use Apitte\Core\Http\ApiRequest;
use Apitte\Core\Http\ApiResponse;
use AipNg\ValueObjects\Web\Email;

#[Path('/users')]
final class UserController implements \Apitte\Core\UI\Controller\IController
{

    #[Path('/search')]
    #[Method('GET')]
    public function search(
        ApiRequest $request,
        ApiResponse $response,
        #[RequestParameter(name: 'email', type: 'email')] Email $email,
        #[RequestParameter(name: 'since', type: 'date')] \DateTimeImmutable $since,
        #[RequestParameter(name: 'ids', type: 'int_array', required: false)] array $ids = [],
    ): ApiResponse
    {
        // $email is AipNg\ValueObjects\Web\Email
        // $since is DateTimeImmutable at 00:00:00
        // $ids is array<int>
        ...
    }

}

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-05-16

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固