spryker/api-platform

ApiPlatform module

Installs: 4 649

Dependents: 2

Suggesters: 0

Security: 0

Stars: 0

Watchers: 0

Forks: 0

pkg:composer/spryker/api-platform

0.5.4 2026-02-24 17:37 UTC

This package is auto-updated.

Last update: 2026-02-25 11:03:26 UTC


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.