定制 spryker/api-platform 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

spryker/api-platform

最新稳定版本:1.8.0

Composer 安装命令:

composer require spryker/api-platform

包简介

ApiPlatform module

README 文档

README

Latest Stable Version Minimum PHP Version

Spryker API Platform Module

Use this module to integrate the API Platform into a Spryker project. A schema-based code generator for API Platform resources in Spryker applications. Define your API resources using YAML schemas and automatically generate PHP classes with full API Platform attribute support.

Overview

This module provides a developer-friendly way to define API Platform resources through declarative schema files, similar to Spryker's Transfer object pattern. Resources can be defined across core, feature, and project layers with automatic merging and validation.

Features

  • 📝 Schema-based Definition: Define resources using YAML
  • 🔄 Multi-layer Support: Core, Feature, and Project layer schemas
  • 🎯 ApiType Isolation: Separate configurations for Storefront, Backend, etc.
  • Comprehensive Validation: Post-merge validation with helpful errors
  • 🚀 Efficient Generation: Generator-based file discovery for memory efficiency
  • 💾 Smart Caching: Automatic cache invalidation based on file changes
  • 🔗 Relationship System: Include related resources via ?include= parameter with JSON:API compliance

Installation

composer require spryker/api-platform

Configuration

Default configuration (can be overridden in the bundle config: '%kernel.project_dir%/config/Symfony/{APPLICATION}/packages/spryker_api_platform.php'):

spryker_api_platform:
  source_directories:
    - src/Spryker
    - src/Pyz
  cache_dir: '%kernel.cache_dir%/api-generator'
  generated_dir: '%kernel.project_dir%/src/Generated/Api'
  debug: '%kernel.debug%'

Usage

# Generate all ApiTypes
docker/sdk glue api:generate

# Generate specific ApiType
docker/sdk glue api:generate Storefront

# Debug a resource
docker/sdk glue api:debug Customer --api-type=Storefront

Relationships

Enable resources to include related resources via the ?include= query parameter with JSON:API compliance.

Quick Example

# Define relationship in parent resource
includes:
  - relationshipName: addresses
    targetResource: CustomersAddresses
    uriVariableMappings:
      customerReference: customerReference

# Define reverse relationship in child resource
includableIn:
  - resource: Customers
    relationshipName: addresses

Request:

GET /customers/customer--35?include=addresses

Key Features:

  • ✅ Declarative YAML configuration
  • ✅ Zero provider changes needed
  • ✅ Automatic validation
  • ✅ Format agnostic (JSON:API, JSON-LD, XML)
  • ✅ Performance optimized (compiled configuration)

For comprehensive documentation, see Relationships Guide.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: proprietary
  • 更新时间: 2025-12-04