PHPackages                             psx/openrpc - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. psx/openrpc

ActiveLibrary[API Development](/categories/api)

psx/openrpc
===========

Model classes to generate an OpenRPC specification in a type-safe way

v0.2.0(5mo ago)316.9k—7.8%3Apache-2.0PHPPHP &gt;=8.1CI passing

Since Apr 7Pushed 5mo ago1 watchersCompare

[ Source](https://github.com/apioo/psx-openrpc)[ Packagist](https://packagist.org/packages/psx/openrpc)[ Docs](https://phpsx.org)[ Fund](https://www.paypal.me/fusioapi)[ GitHub Sponsors](https://github.com/chriskapp)[ RSS](/packages/psx-openrpc/feed)WikiDiscussions main Synced 1w ago

READMEChangelogDependencies (6)Versions (5)Used By (3)

OpenRPC
=======

[](#openrpc)

This library contains model classes to generate an OpenRPC specification in a type-safe way. The models are automatically generated based on the [TypeSchema](https://typeschema.org/) specification (s. `typeschema.json`). The following example shows how you can generate an OpenRPC spec:

```
$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', [
    'required' => ['id', 'name'],
    'properties' => [
        'id' => ['type' => 'integer', 'format' => 'int64'],
        'name' => ['type' => 'string'],
        'tag' => ['type' => 'string'],
    ]
]);

$schemas->put('Pets', [
    'type' => 'array',
    'items' => ['$ref' => '#/components/schemas/Pet'],
]);

$components = new Components();
$components->setSchemas($schemas);

$openRPC = new OpenRPC();
$openRPC->setInfo($info);
$openRPC->setServers([$server]);
$openRPC->setMethods($methods);
$openRPC->setComponents($components);

echo json_encode($openRPC, JSON_PRETTY_PRINT);
```

This would result in the following JSON:

```
{
  "openrpc": "1.3.0",
  "info": {
    "title": "Petstore",
    "license": {
      "name": "MIT"
    },
    "version": "1.0.0"
  },
  "servers": [
    {
      "url": "http:\/\/localhost:8080"
    }
  ],
  "methods": [
    {
      "name": "list_pets",
      "summary": "List all pets",
      "params": [
        {
          "name": "limit",
          "description": "How many items to return at one time (max 100)",
          "required": false,
          "schema": {
            "type": "integer",
            "minimum": 1
          }
        }
      ],
      "result": {
        "name": "pets",
        "description": "A paged array of pets",
        "schema": {
          "$ref": "#\/components\/schemas\/Pets"
        }
      },
      "errors": [
        {
          "code": 100,
          "message": "pets busy"
        }
      ]
    }
  ],
  "components": {
    "schemas": {
      "Pet": {
        "required": [
          "id",
          "name"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int64"
          },
          "name": {
            "type": "string"
          },
          "tag": {
            "type": "string"
          }
        }
      },
      "Pets": {
        "type": "array",
        "items": {
          "$ref": "#\/components\/schemas\/Pet"
        }
      }
    }
  }
}
```

Contribution
------------

[](#contribution)

If you want to suggest changes please only change the `typeschema.json` specification and then run the `php gen.php` script to regenerate all model classes.

###  Health Score

43

—

FairBetter than 89% of packages

Maintenance69

Regular maintenance activity

Popularity31

Limited adoption so far

Community14

Small or concentrated contributor base

Maturity47

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~327 days

Total

4

Last Release

178d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/2505846?v=4)[Christoph Kappestein](/maintainers/chriskapp)[@chriskapp](https://github.com/chriskapp)

---

Top Contributors

[![chriskapp](https://avatars.githubusercontent.com/u/2505846?v=4)](https://github.com/chriskapp "chriskapp (8 commits)")

---

Tags

modeldtoopenrpc

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

![Health badge](/badges/psx-openrpc/health.svg)

```
[![Health](https://phpackages.com/badges/psx-openrpc/health.svg)](https://phpackages.com/packages/psx-openrpc)
```

###  Alternatives

[phpexperts/simple-dto

A quick and easy DTO package.

511.1M7](/packages/phpexperts-simple-dto)[rekalogika/mapper

An object mapper for PHP and Symfony. Maps an object to another object. Primarily used for transforming an entity to a DTO and vice versa.

3850.9k1](/packages/rekalogika-mapper)[joskolenberg/laravel-jory

Create a flexible API for your Laravel application using json based queries.

4513.9k](/packages/joskolenberg-laravel-jory)[artyuum/request-dto-mapper-bundle

This bundle provides an easy way to automatically map the incoming request data to a DTO and optionally validate it.

516.0k](/packages/artyuum-request-dto-mapper-bundle)[formapro/values

Alter ego objects. Highly efficient way of building models, api clients and so on

3010.4k8](/packages/formapro-values)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
