abaris / wot
A lightweight PHP library for working with Web of Things (WoT) Thing Descriptions (TD).
v0.1.0
2024-11-23 21:54 UTC
Requires
- php: >=8.1
- justinrainbow/json-schema: ^6.0
Requires (Dev)
- ockcyp/covers-validator: v1.6.0
- phan/phan: ^5.3
- php-parallel-lint/php-console-highlighter: 1.0.0
- php-parallel-lint/php-parallel-lint: ^1.4
- phpstan/phpstan: ^2.0
- phpunit/phpunit: ^9.6
- spatie/phpunit-watcher: ^1.24
- squizlabs/php_codesniffer: ^3.11
README
A lightweight PHP library for working with Web of Things (WoT) Thing Descriptions (TD). It includes features to parse, validate, and generate TD documents. It adheres to the W3C TD JSON Schema but does not follow the W3C WoT Scripting API.
Features
- Describe and document Thing Descriptions programmatically.
- Generate compliant Thing Descriptions programmatically.
- Parse Thing Descriptions from JSON format.
- Validate Thing Descriptions against the W3C WoT TD schema.
Installation
Install the library via Composer:
composer require abaris/wot
Usage
use Abaris\WoT\Core\Describe\ThingDescription; use Abaris\WoT\Core\Generate\Generator; $td = new ThingDescription(); $td->setTitle("Smart Thermostat") ->addProperty("temperature", [ "type" => "number", "forms" => [ [ "href" => "/properties/temperature", "op" => ["readproperty"], ], ], ]) ->addProperty("status", [ "type" => "boolean", "forms" => [ [ "href" => "/properties/status", "op" => ["readproperty"], ], ], ]); $json = Generator::generate($td); echo $json;
Contributing
See CONTRIBUTING.md for contribution guidelines.
License
This library is licensed under the MIT License.