Skip to content

feat(php): Add PHP SDK implementation #5

@clemensv

Description

@clemensv

Summary

Add a PHP SDK for JSON Structure schema and instance validation.

Background

PHP powers approximately 77% of websites with a known server-side language. With Laravel, Symfony, and WordPress dominating web development, a PHP SDK provides schema validation for the massive PHP ecosystem including:

  • Laravel/Symfony API validation
  • WordPress plugin data validation
  • Composer package ecosystem
  • Legacy PHP application modernization

Implementation Guide

Follow the SDK Guidelines document: SDK-GUIDELINES.md

This document contains:

  • Required components (SchemaValidator, InstanceValidator, ErrorCodes, JsonSourceLocator)
  • Complete type system reference (34 primitive types + compound types)
  • Keywords reference (what to implement, what NOT to implement)
  • Error codes reference (assets/error-messages.json)
  • Test assets for conformance testing
  • Conformance checklist

Requirements

Core Features

  • Schema Validation: Validate JSON Structure schema documents for conformance
  • Instance Validation: Validate JSON instances against JSON Structure schemas
  • Error Reporting: Line/column information for validation errors (when source JSON available)
  • Full Type Support: All 34 primitive and compound types from JSON Structure Core v0

Technical Requirements

  • PHP 8.1+ (for modern type system, enums, readonly properties)
  • Composer for distribution
  • Use json_decode() / json_encode() for JSON parsing
  • PSR-4 autoloading
  • PHPUnit for testing
  • No framework dependencies (pure PHP, works with any framework)

Package Structure

php/
 composer.json
 README.md
 phpunit.xml
 src/
    JsonStructure/
        SchemaValidator.php
        InstanceValidator.php
        Types.php
        ErrorCodes.php
        JsonSourceLocator.php
        ValidationResult.php
 tests/
     SchemaValidatorTest.php
     InstanceValidatorTest.php
     TestAssets.php

CI/CD

  • GitHub Actions workflow with PHP matrix (8.1, 8.2, 8.3)
  • Test on ubuntu-latest
  • Integration with shared test-assets/ for cross-SDK validation

Reference Materials

Acceptance Criteria

  • All test-assets pass validation
  • CI workflow passes on PHP 8.1, 8.2, 8.3
  • README with installation and usage examples
  • Conformance checklist completed (see SDK-GUIDELINES.md)
  • Published to Packagist (or ready for publication)

Metadata

Metadata

Assignees

Labels

copilotFor GitHub Copilot coding agent

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions