1. Go to this page and download the library: Download synthetism/unit-php library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
synthetism / unit-php example snippets
declare(strict_types=1);
use Unit\Capabilities;
use Unit\Schema;
use Unit\TeachingContract;
use Unit\ToolSchema;
use Unit\Unit;
use Unit\UnitCore;
use Unit\UnitProps;
use Unit\UnitSchema;
use Unit\Validator;
final class EchoUnit extends Unit
{
protected function __construct(UnitProps $props)
{
parent::__construct($props);
}
public static function create(): self
{
return new self(UnitProps::create([
'dna' => UnitSchema::create('echo', '1.0.0', 'Echoes text back'),
'created' => new \DateTimeImmutable(),
]));
}
protected function build(): UnitCore
{
$capabilities = Capabilities::create($this->id(), [
'say' => [$this, 'say'],
]);
$schema = Schema::create($this->id(), [
'say' => ToolSchema::create('say', 'Echo text back', [
'type' => 'object',
'properties' => ['text' => ['type' => 'string']],
'