Download the PHP package xterr/php-ubl-generator without Composer
On this page you can find all versions of the php package xterr/php-ubl-generator. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download xterr/php-ubl-generator
More information about xterr/php-ubl-generator
Files in xterr/php-ubl-generator
Package php-ubl-generator
Short Description UBL 2.x XSD-to-PHP 8.2+ code generator — produces typed classes with XML mapping attributes from OASIS XSD schemas
License MIT
Informations about the package php-ubl-generator
PHP UBL Generator
XSD-to-PHP code generator for UBL 2.x documents. Reads OASIS UBL schemas and emits typed PHP 8.2+ classes with XML mapping attributes, optional codelist enums from Genericode files, and configurable property bindings.
Features
- UBL 2.x Schemas — Supports versions 2.1, 2.2, 2.3, 2.4
- All UBL Namespaces — CBC, CAC, EXT, SBC, SIG, SAC with universal resolution
- Typed Classes —
final classwith private properties, typed getters, fluent setters - PHP 8 Attributes —
#[XmlRoot],#[XmlType],#[XmlElement],#[XmlAttribute],#[XmlValue] - Codelist Enums — Parse OASIS Genericode (
.gc) files intostring-backed PHP enums with#[CodelistMeta] - Union Type Bindings — Bind multiple codelist enums to a single property as PHP union types
- Setter Validation — Inline type checks, patterns, and enumeration validation
- Validator Attributes — Optional
symfony/validator#[Assert\*]attribute generation - Configurable — YAML config with namespace overrides, include/exclude filters, naming customization
- Bring Your Own Schemas — Download UBL schemas from OASIS and point the generator at them
Installation
Generated classes depend on the runtime package:
Requirements:
- PHP 8.2 or higher
ext-domext-libxmlext-mbstring
Quick Start
Generate classes from UBL schemas
Generated output structure
Configuration
Copy the default config and customize:
Codelist Support
Point the generator at a directory of OASIS Genericode (.gc) files to generate string-backed PHP enums:
Generated enum:
Property Bindings
Bind codelist enums to specific XSD properties, replacing the default CBC Code type:
Single bindings produce:
Union bindings produce PHP union types:
Namespace Handling
All standard UBL 2.x namespaces are supported with universal resolution:
| Namespace | Prefix | Output | Description |
|---|---|---|---|
| CommonBasicComponents | cbc |
Cbc/ |
Leaf types (value + attributes) |
| SignatureBasicComponents | sbc |
Cbc/ |
Signature leaf types (same pattern) |
| CommonExtensionComponents | ext |
Cbc/ or Cac/ |
Leaf types → Cbc/, aggregates → Cac/ |
| CommonAggregateComponents | cac |
Cac/ |
Aggregate types (child elements) |
| SignatureAggregateComponents | sac |
Cac/ |
Signature aggregate types |
| CommonSignatureComponents | sig |
Cac/ |
Signature components |
Types are classified structurally: complex types with simpleContent extensions become leaf classes in Cbc/, complex types with child element sequences become aggregate classes in Cac/.
CLI Options
| Option | Description |
|---|---|
--config, -c |
Path to YAML configuration file |
--schema-dir, -s |
Path to XSD schema directory |
--schema-version |
UBL schema version (2.1, 2.2, 2.3, 2.4) |
--output-dir, -o |
Output directory for generated classes |
--namespace |
Root PHP namespace |
--codelist-dir |
Path to directory containing .gc codelist files |
--force, -f |
Actually generate files (without this, dry-run only) |
Architecture
Two packages work together:
| Package | Role | Install |
|---|---|---|
| xterr/php-ubl-generator (this) | Dev-time code generator | composer require --dev |
| xterr/php-ubl | Runtime XML mapping & serialization | composer require |
The generator reads XSD schemas and Genericode files, then emits PHP classes that use attributes from xterr/php-ubl. At runtime, only the lightweight xterr/php-ubl package is needed for XML serialization and deserialization.
Development
CI
Tests run on PHP 8.2, 8.3, and 8.4 via GitHub Actions. Tagged releases are automatically notified to Packagist.
License
MIT — Copyright (c) 2026 Ceana Razvan
All versions of php-ubl-generator with dependencies
ext-dom Version *
ext-libxml Version *
ext-mbstring Version *
goetas-webservices/xsd-reader Version ^0.4
nette/php-generator Version ^4.1
symfony/config Version ^7.0 || ^8.0
symfony/console Version ^7.0 || ^8.0
symfony/filesystem Version ^7.0 || ^8.0
symfony/finder Version ^7.0 || ^8.0
symfony/string Version ^7.0 || ^8.0
symfony/yaml Version ^7.0 || ^8.0
xterr/php-ubl Version ^1.2