socialdept / atp-schema
ATProto Lexicon parser and validator with DTO generation for Laravel
Requires
- php: ^8.3
- guzzlehttp/guzzle: ^7.5|^8.0
- illuminate/cache: ^11.0|^12.0|^13.0
- illuminate/console: ^11.0|^12.0|^13.0
- illuminate/support: ^11.0|^12.0|^13.0
- socialdept/atp-support: ^0.3.4
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.89
- orchestra/testbench: ^9.0|^10.0|^11.0
- phpunit/phpunit: ^11.0|^12.0
Suggests
None
Provides
None
Conflicts
None
Replaces
None
README
Parse, validate, and transform AT Protocol Lexicon schemas in Laravel.
This package loads AT Protocol lexicons into a Laravel app, validates records against them, ships PHP classes for the standard AT Protocol and Bluesky lexicons, generates classes for any other lexicon, and gives you commands to create, lint and check lexicons of your own before you publish them. To learn all about it, head over to the documentation.
Here are a few short examples of what you can do. Validate a record against a lexicon:
use SocialDept\AtpSchema\Facades\Schema; Schema::validate('app.bsky.feed.post', [ 'text' => 'Hello, AT Protocol!', 'createdAt' => '2024-01-01T12:00:00Z', ]); // true
Build records with the bundled classes:
use SocialDept\AtpSchema\Generated\App\Bsky\Feed\Post; $post = new Post(text: 'Hello ATP!', createdAt: now()); $post->toRecord(); // ['text' => 'Hello ATP!', 'createdAt' => '...', '$type' => 'app.bsky.feed.post']
Generate classes for any lexicon:
php artisan schema:generate app.bsky.feed.post --with-dependencies
Write lexicons of your own, and check them before you publish:
php artisan schema:new record com.example.thing php artisan schema:lint php artisan schema:breaking
Documentation
You'll find the documentation on https://socialde.pt/docs/atp-schema.
Find yourself stuck using the package? Found a bug? Do you have general questions or suggestions for improving it? Feel free to create an issue on GitHub.
Testing
vendor/bin/phpunit
Contributing
Please see CONTRIBUTING for details.
License
The MIT License (MIT). Please see LICENSE for more information.
