sapphire/mapper 问题修复 & 功能扩展

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

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

sapphire/mapper

Composer 安装命令:

composer require sapphire/mapper

包简介

Mapper library written in PHP for AWS DynamoDB

README 文档

README

sapphire logo

PHP Class Mapper for AWS DynamoDB

This library converts your PHP class with the help of PHP attributes to the array structure needed to work with AWS DynamoDB.

Example

Your class:

#[DynamoObject(tableName: "products")]
class Product
{
    #[DynamoField(type: DynamoType::STRING)]
    private string $id;

    #[DynamoField(type: DynamoType::STRING)]
    public string $name;

    #[DynamoField(type: DynamoType::NUMBER)]
    public float $price;

    #[DynamoField(type: DynamoType::LIST)]
    public array $tags = [];

    public function __construct()
    {
        $this->id = uniqid();
    }

    public function getId(): string
    {
        return $this->id;
    }
}

Usage of the mapper:

$product = new Product();
$product->name = "Dominator 2025";
$product->price = 13.37;
$product->tags = ["top seller", "hot", 2025];

$mapper = new DynamoMapper();

$item = $mapper->toPutItem($product);

Result:

// The $item looks like this:
array:2 [
  "TableName" => "products"
  "Item" => array:4 [
    "id" => array:1 [
      "S" => "6857e3326fdc2"
    ]
    "name" => array:1 [
      "S" => "Dominator 2025"
    ]
    "price" => array:1 [
      "N" => "13.37"
    ]
    "tags" => array:1 [
      "L" => array:3 [
        0 => array:1 [
          "S" => "top seller"
        ]
        1 => array:1 [
          "S" => "hot"
        ]
        2 => array:1 [
          "N" => "2025"
        ]
      ]
    ]
  ]
]

Installation

composer req <todo>

Run tests

Unit tests:

composer test:unit

Feature/Integration tests:

composer test:feature

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-06-22

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固