A PHP implementation for validating JSON structures against JSON Schema drafts 3, 4, 6, and 7.
JSON Schema for PHP is a library that validates JSON data structures against JSON Schema specifications. It allows PHP developers to ensure that JSON input, configuration files, or API payloads conform to expected formats and constraints defined in a schema. The library supports multiple JSON Schema drafts and includes features like type coercion and default value application.
PHP developers building applications that consume JSON data, such as REST APIs, configuration systems, or data processing pipelines requiring strict structural validation.
Developers choose this library for its robust compliance with JSON Schema standards, support for multiple drafts, and practical features like type coercion and default application that simplify validation of real-world data like HTTP requests.
JSON Schema for PHP
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Supports JSON Schema drafts 3, 4, 6, and 7, making it versatile for validating schemas from various eras without needing multiple libraries, as evidenced by the compliance badges in the README.
Automatically converts HTTP request strings to typed values like booleans and numbers using CHECK_MODE_COERCE_TYPES, simplifying validation in web applications where input is often string-based.
Applies schema-defined defaults to missing properties during validation with CHECK_MODE_APPLY_DEFAULTS, reducing manual data handling and ensuring completeness in JSON documents.
Offers configurable flags like strict mode, exception throwing, and format disabling, allowing developers to tailor validation behavior to specific needs, as detailed in the configuration options table.
Lacks support for newer JSON Schema drafts (2019-09, 2020-12), limiting access to modern features, and the README explicitly warns that newer draft features might not be supported.
Type coercion and default application modify the original data, which the README notes can lead to unexpected changes, requiring careful management in sensitive applications.
Inline reference resolution requires additional setup with SchemaStorage and Factory, adding complexity and boilerplate code compared to simpler validation libraries or built-in solutions.