spryker / api-platform
ApiPlatform module
Installs: 4 804
Dependents: 2
Suggesters: 0
Security: 0
Stars: 0
Watchers: 0
Forks: 0
pkg:composer/spryker/api-platform
Requires
- php: >=8.3
- api-platform/api-pack: ^1.4.0
- api-platform/doctrine-common: ^4.2.0
- api-platform/doctrine-orm: ^4.2.0
- api-platform/documentation: ^4.2.0
- api-platform/hal: ^4.2.0
- api-platform/http-cache: ^4.2.0
- api-platform/hydra: ^4.2.0
- api-platform/json-api: ^4.2.0
- api-platform/json-schema: ^4.2.0
- api-platform/jsonld: ^4.2.0
- api-platform/metadata: ^4.2.0
- api-platform/openapi: ^4.2.0
- api-platform/serializer: ^4.2.0
- api-platform/state: ^4.2.0
- api-platform/symfony: ^4.2.0
- api-platform/validator: ^4.2.0
- friendsofcxml/cxml-php: ^2.0.0
- spryker/kernel: ^3.48.0
- spryker/laminas: ^1.0.0
- spryker/log: ^3.0.0
- spryker/transfer: ^3.27.0
- symfony/config: ^6.0.0 || ^7.0.0
- symfony/console: ^6.0.0 || ^7.0.0
- symfony/finder: ^6.0.0 || ^7.0.0
- symfony/http-kernel: ^6.0.0 || ^7.0.0
- symfony/yaml: ^6.0.0 || ^7.0.0
Requires (Dev)
README
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.