PHPackages                             gdbots/pbjc - 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. gdbots/pbjc

ActiveLibrary

gdbots/pbjc
===========

Compiler for converting pbj schemas into jsonschema, php, js, etc.

v0.4.0(7y ago)05.6k1[1 issues](https://github.com/gdbots/pbjc-php/issues)7Apache-2.0PHPPHP &gt;=7.1

Since Mar 10Pushed 3mo ago7 watchersCompare

[ Source](https://github.com/gdbots/pbjc-php)[ Packagist](https://packagist.org/packages/gdbots/pbjc)[ Docs](https://github.com/gdbots/pbjc-php)[ RSS](/packages/gdbots-pbjc/feed)WikiDiscussions master Synced 2mo ago

READMEChangelog (10)Dependencies (7)Versions (23)Used By (7)

pbjc-php
========

[](#pbjc-php)

[![Build Status](https://camo.githubusercontent.com/06e76114c15fce6c1703a09a4eb2b579bd8c06f30ec1319749a9ae0bde6fc83a/68747470733a2f2f6170692e7472617669732d63692e6f72672f6764626f74732f70626a632d7068702e737667)](https://travis-ci.org/gdbots/pbjc-php)[![Code Climate](https://camo.githubusercontent.com/55ee7be63554d0a2e4c34cda74607e6b9fa63db525ffe51ff67ab377b21d747f/68747470733a2f2f636f6465636c696d6174652e636f6d2f6769746875622f6764626f74732f70626a632d7068702f6261646765732f6770612e737667)](https://codeclimate.com/github/gdbots/pbjc-php)

Compiler for converting pbj schemas into jsonschema, php, js, etc.

Language Guide
==============

[](#language-guide)

This guide describes how to use the XML language to structure your schema file syntax and how to generate data classes files.

### References

[](#references)

Let's start by defining each of the elements and key options used across the compiler.

- **Schema:** The purpose of a Schema is to define a pbj message, with the fields and related mixins (other schemas used to extend the schema capability).
- **Enum:** An Enum is a collection of key-value, used in schema fields (see Enumerations below).
- **SchemaId:** A Schema fully qualified name (id).

    - Schema Id: `pbj:vendor:package:category:message:version`
    - Schema Curie Major: `vendor:package:category:message:v#`
    - Schema Curie: `vendor:package:category:message`
    - Schema QName: `vendor:message`
- **SchemaVersion:** Similar to semantic versioning but with dashes and no "alpha, beta, etc." qualifiers.

    - Schema Version Format: `major-minor-patch`

### Defining A Schema

[](#defining-a-schema)

First let's look at a very simple example. Let's say you want to define a **mixin** schema, with slug and name fields. Here's the `.xml` file you use to define the schema.

```

```

Each schema required a few basic elements: id and fields. The id is a unique identifier follow a basic schema-id format `pbj:vendor:package:category:message:version` (version = major-minor-patch). The fields is an array of associated fields used by the schema. In the above example, the store schema contains a slug and a title.

Since we are creating a mixin schema, we set in the second line `mixin = true`.

In addition, we allow to add language specific options which will be used while generating the language output file.

#### Schema Field Types

[](#schema-field-types)

The following list contains all available field types:

```
- big-int
- binary
- blob
- boolean
- date
- date-time
- decimal
- dynamic-field
- float
- geo-point
- identifier
- float
- int
- medium-blob
- medium-int
- medium-text
- microtime
- signed-big-int
- signed-int
- signed-medium-int
- signed-small-int
- signed-tiny-int
- small-int
- string
- text
- time-uuid
- timestamp
- tiny-int
- uuid

```

#### Default Values

[](#default-values)

When a schema is parsed, if the encoded schema does not contain a particular singular element, the corresponding field in the parsed object is set to the default value for that field. These defaults are type-specific:

```
- For strings, the default value is the empty string.
- For bytes, the default value is empty bytes.
- For bools, the default value is false.
- For numeric types, the default value is zero.
- For each of the other field types, the default value is null.

```

#### Enumerations

[](#enumerations)

When you're defining a schema, you might want one of its fields to only have one of a pre-defined list of values. For example, let's say you want to add a `Reason` enum field, where the values can be `INVALID`, `FAILED` or `DELETED`.

```

    invalid

```

The define the enum in `enums.xml`:

```

```

From the above example you can see we defined the enum keys and values for a specific schema and called it directly from the field.

> **Note:** We can also define the PHP namespace where the enum class will be generated to.

There are 2 kinds of enum types, `StringEnum` and `IntEnum`. We separated to simplified the field type and values.

> **Note:** major database for example MySQL, DynamoDB and other define enum based on type - string or int.

#### Using Message Types

[](#using-message-types)

You can use `Message` and `MessageRef` as field types. For example, let's say you wanted to include related messages in each Story schema:

```

    gdbots:pbjx:mixin:request

```

The `any-of` attribute define the message id that will be used to pull the message details.

### Full Schema Options

[](#full-schema-options)

```

        {string}

          {pbj:vendor:package:category}

          {string}
          {string}
          {string}

          {string}
          {string}
          {string}

      {pbj:vendor:package:category:vmajor}

```

```

```

> **Note:** For each `php-options` you can also add dynamic tags. For example:

```

use Gdbots\Pbj\MessageRef;
        ]]>

/**
 * @param string $tag
 * @return MessageRef
 */
public function generateMessageRef($tag = null)
{
    return new MessageRef(static::schema()->getCurie(), $this->get('command_id'), $tag);
}
        ]]>

```

Basic Usage
===========

[](#basic-usage)

```
pbjc --language[=LANGUAGE] --config[=CONFIG]
```

OptionNotes-l or --language\[=LANGUAGE\]The generated language \[default: "php"\]-c or --config\[=CONFIG\]The pbjc config yaml fileDefine compile settings in `pbjc.yml` file:

```
namespaces:
  - :
  - :

languages:
  php:
    output:
    manifest: /
```

> **Note:** by default the compiler searches for `pbjc.yml` in the root folder.

###  Health Score

39

—

LowBetter than 86% of packages

Maintenance53

Moderate activity, may be stable

Popularity18

Limited adoption so far

Community20

Small or concentrated contributor base

Maturity58

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 92.7% 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 ~171 days

Recently: every ~748 days

Total

22

Last Release

114d ago

Major Versions

v0.4.0 → v1.x-dev2026-01-24

PHP version history (3 changes)v0.1.0PHP &gt;=5.6

v0.3.0PHP &gt;=7.1

v1.x-devPHP &gt;=8.1

### Community

Maintainers

![](https://www.gravatar.com/avatar/04ecf55609310eefdd08182fdc75aec01f6c5aa9657ec6729ac54e6f5dd5f0ef?d=identicon)[gdbrown](/maintainers/gdbrown)

---

Top Contributors

[![excelwebzone](https://avatars.githubusercontent.com/u/4467438?v=4)](https://github.com/excelwebzone "excelwebzone (422 commits)")[![gdbrown](https://avatars.githubusercontent.com/u/3344831?v=4)](https://github.com/gdbrown "gdbrown (33 commits)")

---

Tags

pbjpbjx

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/gdbots-pbjc/health.svg)

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

###  Alternatives

[sylius/sylius

E-Commerce platform for PHP, based on Symfony framework.

8.4k5.6M651](/packages/sylius-sylius)[simplesamlphp/simplesamlphp

A PHP implementation of a SAML 2.0 service provider and identity provider.

1.1k12.4M193](/packages/simplesamlphp-simplesamlphp)[shopware/platform

The Shopware e-commerce core

3.3k1.5M3](/packages/shopware-platform)[drupal/core

Drupal is an open source content management platform powering millions of websites and applications.

19462.3M1.3k](/packages/drupal-core)[sulu/sulu

Core framework that implements the functionality of the Sulu content management system

1.3k1.3M152](/packages/sulu-sulu)[prestashop/prestashop

PrestaShop is an Open Source e-commerce platform, committed to providing the best shopping cart experience for both merchants and customers.

9.0k15.4k](/packages/prestashop-prestashop)

PHPackages © 2026

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