PHP code example of psx / openrpc
1. Go to this page and download the library: Download psx/openrpc 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/ */
psx / openrpc example snippets
$license = new License();
$license->setName('MIT');
$info = new Info();
$info->setVersion('1.0.0');
$info->setTitle('Petstore');
$info->setLicense($license);
$server = new Server();
$server->setUrl('http://localhost:8080');
$params = [];
$content = new ContentDescriptor();
$content->setName('limit');
$content->setDescription('How many items to return at one time (max 100)');
$content->setRequired(false);
$content->setSchema((object) ['type' => 'integer', 'minimum' => 1]);
$params[] = $content;
$result = new ContentDescriptor();
$result->setName('pets');
$result->setDescription('A paged array of pets');
$result->setSchema((object) ['$ref' => '#/components/schemas/Pets']);
$errors = [];
$error = new Error();
$error->setCode(100);
$error->setMessage('pets busy');
$errors[] = $error;
$methods = [];
$method = new Method();
$method->setName('list_pets');
$method->setSummary('List all pets');
$method->setParams($params);
$method->setResult($result);
$method->setErrors($errors);
$methods[] = $method;
$schemas = new Schemas();
$schemas->put('Pet', [
'