aaronbullard / php-schema
Installs: 8
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 1
Forks: 0
Open Issues: 0
pkg:composer/aaronbullard/php-schema
Requires
- php: ^7.1
- justinrainbow/json-schema: ^5.2
Requires (Dev)
- mockery/mockery: ^1.1
- phpunit/phpunit: ^7.3
This package is auto-updated.
Last update: 2025-10-16 10:43:20 UTC
README
Self validating PHP objects from JSON Schema
Installation
Library
git clone https://github.com/aaronbullard/php-schema.git
Composer
composer require aaronbullard/php-schema
Testing
composer test
Usage
PhpSchema provides a quick solution to roll objects from JSON Schema.
Objects self validate during construction and when mutated.
In keeping with DDD principles, PhpSchema objects should always be in a valid state. Therefore all required properties must be passed through the constructor. Any optional properties can be passed after instantiation.
Validation is built off of JsonSchema\Validator from justinrainbow/json-schema
Examples
- PublicProperties Trait
- MethodAccess Trait
- Converting to Array, Json, or StdClass
- Integrating with non-PhpSchema classes
For more examples, see the tests: tests\ModelTest.php