PHPackages                             cycle/schema-renderer - 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. cycle/schema-renderer

ActiveLibrary

cycle/schema-renderer
=====================

Utils for Cycle ORM Schema rendering

1.4.0(6mo ago)10282.7k—10%6[2 issues](https://github.com/cycle/schema-renderer/issues)9MITPHPPHP &gt;=8.1CI passing

Since Oct 4Pushed 6mo ago3 watchersCompare

[ Source](https://github.com/cycle/schema-renderer)[ Packagist](https://packagist.org/packages/cycle/schema-renderer)[ RSS](/packages/cycle-schema-renderer/feed)WikiDiscussions 1.x Synced 1mo ago

READMEChangelog (7)Dependencies (6)Versions (9)Used By (9)

Cycle ORM Schema renderer
=========================

[](#cycle-orm-schema-renderer)

[![Latest Stable Version](https://camo.githubusercontent.com/9ccd69aecd8440f4500bb2b92c11d8be21b3f30c9bb4e711d85c80dc7adad145/68747470733a2f2f706f7365722e707567782e6f72672f6379636c652f736368656d612d72656e64657265722f762f737461626c65)](https://packagist.org/packages/cycle/schema-renderer)[![build](https://github.com/cycle/schema-renderer/actions/workflows/main.yml/badge.svg)](https://github.com/cycle/schema-renderer/actions/workflows/main.yml)[![static analysis](https://github.com/cycle/schema-renderer/actions/workflows/static.yml/badge.svg)](https://github.com/cycle/schema-renderer/actions/workflows/static.yml)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/43c8132edde40016da07a59f3339daa503569ebaf832074c18be02003a269dfb/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6379636c652f736368656d612d72656e64657265722f6261646765732f7175616c6974792d73636f72652e706e673f623d312e78)](https://scrutinizer-ci.com/g/cycle/schema-renderer/?branch=1.x)[![Codecov](https://camo.githubusercontent.com/ba8c511e16a74a47425c4097d21bceb1b3388c0f65b9d79d0df3cd1b3741c3c4/68747470733a2f2f636f6465636f762e696f2f67682f6379636c652f736368656d612d72656e64657265722f6272616e63682f312e782f67726170682f62616467652e737667)](https://codecov.io/gh/cycle/schema-renderer/)

This package may be used to render Cycle ORM Schema in a terminal or generate php representation.

Installation
------------

[](#installation)

The preferred way to install this package is through [Composer](https://getcomposer.org/download/):

```
composer require cycle/schema-renderer
```

Example
-------

[](#example)

### Convert schema to array

[](#convert-schema-to-array)

```
$schema = new Schema([...]);
$converter = new \Cycle\Schema\Renderer\SchemaToArrayConverter();

$schemaArray = $converter->convert($schema);
```

If passed `SchemaInterface` doesn't contain `toArray()` method then the `SchemaToArrayConverter` will convert only common properties from `Cycle\ORM\SchemaInterface`. Null values will be skipped also.

In this case Iif you want to use custom properties you can pass them to the constructor

```
$converter = new \Cycle\Schema\Renderer\SchemaToArrayConverter();

$schemaArray = $converter->convert($schema, [
    42,
    CustomClass::CUSTOM_PROPERTY,
    ...
]);
```

### Render schema to a terminal

[](#render-schema-to-a-terminal)

```
use Cycle\Schema\Renderer\OutputSchemaRenderer;

$output = new \Symfony\Component\Console\Output\ConsoleOutput();

$renderer = new OutputSchemaRenderer(colorize: true);

$output->write($renderer->render($schemaArray));
```

By default, `DefaultSchemaOutputRenderer` renders in template only common properties and relations. Custom properties will be rendered as is in separated block. If you want to extend default rendering template you can create custom renderers and add them to the Output renderer.

```
use Cycle\Schema\Renderer\ConsoleRenderer\Renderer;
use Cycle\Schema\Renderer\ConsoleRenderer\Formatter;
use Cycle\Schema\Renderer\OutputSchemaRenderer;

class CustomPropertyRenderer implements Renderer {

    public function render(Formatter $formatter, array $schema, string $role): string
    {
        $data = $schema['my_custom_property'] ?? null;

        return \sprintf(
            '%s: %s',
            $formatter->title($this->title),
            $data === null ? $formatter->error('not defined') : $formatter->typecast($data)
        );
    }
}

$renderer = new OutputSchemaRenderer();

$renderer->addRenderer(
    new CustomPropertyRenderer(),
    new PropertyRenderer('my_custom_property', 'My super property')
);

$output->write($renderer->render($schemaArray))
```

### Store schema in a PHP file

[](#store-schema-in-a-php-file)

```
use Cycle\Schema\Renderer\PhpSchemaRenderer;

$path = __DIR__. '/schema.php'

$renderer = new PhpSchemaRenderer();

\file_put_contents($path, $renderer->render($schemaArray));
```

The Renderer generates valid PHP code, in which constants from Cycle ORM classes are substituted for better readability.

License:
--------

[](#license)

The MIT License (MIT). Please see [`LICENSE`](./LICENSE) for more information. Maintained by [Spiral Scout](https://spiralscout.com).

###  Health Score

52

—

FairBetter than 96% of packages

Maintenance63

Regular maintenance activity

Popularity44

Moderate usage in the ecosystem

Community25

Small or concentrated contributor base

Maturity64

Established project with proven stability

 Bus Factor1

Top contributor holds 53.8% 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 ~213 days

Recently: every ~354 days

Total

8

Last Release

196d ago

PHP version history (2 changes)1.0.0PHP &gt;=7.4

1.3.0PHP &gt;=8.1

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/796136?v=4)[Anton Tsitou](/maintainers/wolfy-j)[@wolfy-j](https://github.com/wolfy-j)

---

Top Contributors

[![roxblnfk](https://avatars.githubusercontent.com/u/4152481?v=4)](https://github.com/roxblnfk "roxblnfk (14 commits)")[![butschster](https://avatars.githubusercontent.com/u/773481?v=4)](https://github.com/butschster "butschster (7 commits)")[![DAGpro](https://avatars.githubusercontent.com/u/9422078?v=4)](https://github.com/DAGpro "DAGpro (2 commits)")[![msmakouz](https://avatars.githubusercontent.com/u/67324318?v=4)](https://github.com/msmakouz "msmakouz (1 commits)")[![puzzledpolymath](https://avatars.githubusercontent.com/u/162779269?v=4)](https://github.com/puzzledpolymath "puzzledpolymath (1 commits)")[![roquie](https://avatars.githubusercontent.com/u/3214290?v=4)](https://github.com/roquie "roquie (1 commits)")

---

Tags

hacktoberfest

###  Code Quality

TestsPHPUnit

Static AnalysisPsalm

Type Coverage Yes

### Embed Badge

![Health badge](/badges/cycle-schema-renderer/health.svg)

```
[![Health](https://phpackages.com/badges/cycle-schema-renderer/health.svg)](https://phpackages.com/packages/cycle-schema-renderer)
```

###  Alternatives

[laravel/horizon

Dashboard and code-driven configuration for Laravel queues.

4.1k84.2M225](/packages/laravel-horizon)[shopware/platform

The Shopware e-commerce core

3.3k1.5M3](/packages/shopware-platform)[danog/madelineproto

Async PHP client API for the telegram MTProto protocol.

3.4k855.0k18](/packages/danog-madelineproto)[illuminate/support

The Illuminate Support package.

582107.1M34.5k](/packages/illuminate-support)[scienta/doctrine-json-functions

A set of extensions to Doctrine that add support for json query functions.

58723.9M36](/packages/scienta-doctrine-json-functions)[temporal/sdk

Temporal SDK

4002.2M18](/packages/temporal-sdk)

PHPackages © 2026

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