Download the PHP package xterr/php-espd without Composer
On this page you can find all versions of the php package xterr/php-espd. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download xterr/php-espd
More information about xterr/php-espd
Files in xterr/php-espd
Package php-espd
Short Description Typed PHP classes for ESPD (European Single Procurement Document) based on ESPD-EDM v4.1.0 / UBL 2.3
License MIT
Informations about the package php-espd
PHP ESPD
Typed PHP classes for ESPD (European Single Procurement Document) based on ESPD-EDM v2.1.1–v4.1.0 / UBL 2.3.
Serialize and deserialize QualificationApplicationRequest and QualificationApplicationResponse documents without DOM code, with multi-version support (v2.1.1 through v4.1.0). Validate documents against the official OP-TED Schematron business rules with 1:1 compliance. Codelist values are PHP enums with full type safety, including union-typed properties for elements that span multiple codelists.
Features
- 325 Generated Classes — 2 document roots, 290 aggregate types, 8 leaf value types, 16 codelist enums, 5 XSD enums, 2 registries
- Business Rule Validation — Official OP-TED ESPD-EDM Schematron rules for v2.1.1, v3.3.0, v4.0.0, and v4.1.0 via SaxonC-HE XSLT processor, 1:1 compliant with the EU reference validator
- Codelist Enums —
CriterionCode,CriterionElement,ResponseData,PropertyGroup,CountryCode,LanguageCode, and 10 more - Union Enum Types —
ExpectedCoderesolves toBooleanGUIControl|FinancialRatio|OccupationCodebased onlistIDat runtime - Multi-Version Support — Deserialize and validate ESPD documents from v2.1.1, v3.3.0, v4.0.0, and v4.1.0. V2 long-form criterion codes automatically merge into the
CriterionCodeenum withV2_prefix and bidirectional v2↔v4 mapping - ESPD Part & Section Classification —
CriterionCode::getPart()returns theEspdPartenum (I–VI per EU Regulation 2016/7),getSection()returns the sub-section letter (A–D, α) per Directive 2014/24/EU Articles 57–62 - Criterion Taxonomy —
ESPD-criterion.xmlships as a resource, deserializable into the generated classes - Full Round-Trip — serialize → deserialize produces identical object graphs
Installation
Requirements:
- PHP 8.2 or higher
ext-domext-libxml
Optional (for validation):
ext-saxonc— SaxonC-HE 12.x (free, MPL-2.0 license)
Quick Start
Deserialize an ESPD Request
Serialize to XML
Validate against EU business rules
Requires the ext-saxonc PHP extension (installation guide).
You can also validate raw XML strings directly:
Work with typed enums
Multi-version deserialization
The library supports ESPD documents from all major versions. V2 long-form criterion codes are automatically resolved:
Criterion Part & Section classification
Every criterion code knows its position in the ESPD form hierarchy defined by Commission Implementing Regulation (EU) 2016/7:
ESPD Form Parts (per EU Regulation 2016/7, Annex 2):
| Part | Title | Sections |
|---|---|---|
| I | Information concerning the procurement procedure | — |
| II | Information concerning the economic operator | A, B, C, D |
| III | Exclusion grounds | A (Criminal convictions), B (Taxes/social security), C (Insolvency/misconduct), D (National grounds) |
| IV | Selection criteria | α (Global indication), A (Suitability), B (Economic standing), C (Technical ability), D (Quality/environment certs) |
| V | Reduction of the number of qualified candidates | — |
| VI | Concluding statements | — |
Union enum — ExpectedCode
ExpectedCode can hold values from three different codelists depending on the criterion context. The listID XML attribute acts as the runtime discriminator:
Load the criterion taxonomy
The full ESPD criterion tree ships as a resource:
Validation
The validation subsystem runs the official OP-TED/ESPD-EDM Schematron business rules via SaxonC-HE. This guarantees 1:1 compliance with the EU reference validator — identical rule IDs, severity levels, and error messages.
Multi-version validation
The validator supports 4 ESPD-EDM version families and automatically detects which rule set to apply based on the document's ProfileExecutionID:
| Version Family | Rule Set | ProfileExecutionID values |
|---|---|---|
VersionFamily::V2 |
v2.1.1 | ESPD-EDMv2.0.0-REGULATED, ESPD-EDMv2.0.0-SELFCONTAINED, ESPD-EDMv2.1.0-REGULATED, ESPD-EDMv2.1.0-SELFCONTAINED, ESPD-EDMv2.1.1-BASIC, ESPD-EDMv2.1.1-EXTENDED |
VersionFamily::V3 |
v3.3.0 | ESPD-EDMv3.0.0, ESPD-EDMv3.0.1, ESPD-EDMv3.1.0, ESPD-EDMv3.2.0, ESPD-EDMv3.3.0 |
VersionFamily::V4_0 |
v4.0.0 | ESPD-EDMv4.0.0 |
VersionFamily::V4_1 |
v4.1.0 | ESPD-EDMv4.1.0 |
Auto-detection (recommended) — the validator reads ProfileExecutionID from the XML and selects the matching rule set:
Explicit version — useful when the document lacks a ProfileExecutionID or you want to force a specific rule set:
If auto-detection fails (missing or unrecognized ProfileExecutionID), a ValidationException is thrown prompting you to specify the version explicitly.
What gets validated
| Category | Rule IDs | Severity |
|---|---|---|
| Cardinality | BR-OTH-04-* |
Fatal |
| Codelist values | auto-generated | Fatal |
| Criterion structure | BR-TC-02 through BR-TC-21 |
Fatal/Error |
| Exclusion criteria | BR-REQ-30 |
Fatal |
| Selection criteria | BR-REQ-40 |
Warning |
| Procurer data | BR-REQ-20-* |
Warning/Error |
| Economic operator | BR-RESP-10-*, BR-RESP-20-* |
Error |
| Other | BR-SC-10, BR-OTH-* |
Mixed |
Validation result API
Each Violation exposes:
| Property | Description |
|---|---|
ruleId |
Schematron rule ID (e.g. BR-OTH-04-01) |
severity |
Severity::Fatal, Severity::Error, or Severity::Warning |
message |
Human-readable error message |
location |
XPath to the failing XML node |
test |
XPath test expression from the rule |
pattern |
Pattern group ID |
Generated Structure
Codelist Enums
| Enum | listID | Values |
|---|---|---|
CriterionCode |
criterion |
crime-org, corruption, fraud, ... (+ getPart(), getSection()) |
EspdPart |
— | I, II, III, IV, V, VI (EU Regulation 2016/7 form Parts) |
CriterionElement |
criterion-element-type |
QUESTION, REQUIREMENT, CRITERION, ... |
ResponseData |
response-data-type |
INDICATOR, AMOUNT, DATE, DESCRIPTION, ... |
PropertyGroup |
property-group-type |
ON*, ONTRUE, ONFALSE |
CountryCode |
country |
ISO 3166-1 codes |
LanguageCode |
language |
ISO 639 codes |
CurrencyCode |
currency |
ISO 4217 codes |
OccupationCode |
occupation |
ESCO occupation codes |
EconomicOperatorSize |
economic-operator-size |
SME, micro, large, ... |
EoRole |
eo-role-type |
Sole tenderer, lead entity, ... |
BooleanGUIControl |
boolean-gui-control-type |
CHECKBOX_TRUE, RADIO_BUTTON_TRUE, ... |
FinancialRatio |
financial-ratio-type |
Ratio types |
ProfileExecutionID |
profile-execution-id |
ESPD-EDMv4.1.0, ... |
AccessRight |
access-right |
Access right codes |
Docrefcontent |
docrefcontent-type |
Document reference content types |
EOID |
eoid-type |
Economic operator ID types |
Codelist Bindings
These properties are typed with codelist enums instead of generic Code:
| Class | Property | Enum |
|---|---|---|
TenderingCriterion |
criterionTypeCode |
CriterionCode |
TenderingCriterionProperty |
typeCode |
CriterionElement |
TenderingCriterionProperty |
valueDataTypeCode |
ResponseData |
TenderingCriterionProperty |
expectedCode |
BooleanGUIControl\|FinancialRatio\|OccupationCode |
TenderingCriterionPropertyGroup |
propertyGroupTypeCode |
PropertyGroup |
Country |
identificationCode |
CountryCode |
Language |
localeCode |
LanguageCode |
Installing SaxonC-HE
The ext-saxonc PHP extension is required only for validation. Serialization and deserialization work without it.
Docker (easiest)
macOS
For Intel Macs, replace arm64 with x86_64 in the download URL.
Linux (Ubuntu/Debian)
Verify
Schema Source
Generated from OP-TED/ESPD-EDM v4.1.0, which uses OASIS UBL 2.3 OS schemas. The XSD schemas and Genericode codelist files are in resources/ (not committed — dev-only). The pre-compiled Schematron XSL validation rules are bundled in resources/validation/ for all 4 version families (v2.1.1, v3.3.0, v4.0.0, v4.1.0). V2.1.1 codelist GC files are in resources/cl/gc/.
Regenerating
The php-espd CLI tool orchestrates the full code generation pipeline:
What it does
- Parses criterion taxonomies — reads ESPD-EDM v2.1.1 and v4.1.0 taxonomy XML files
- Cross-references UUIDs — matches v2 long-form codes to v4 short-form codes by criterion UUID (+ 6 manual EO_DATA equivalences for codes where v4 uses structured IDs instead of UUIDs)
- Generates v2→v4 mapping file — writes
resources/criterion/v2-to-v4-mapping.php(v2 → v4 lookup) 3b. Generates code-to-part mapping — parsescriterionList.xmlfor exclusion/selection classification, resolves sub-sections from v2 code prefixes and EU Regulation 2016/7 Annex 2, writesresources/criterion/code-to-part.php - Generates Genericode file — writes
resources/codelists/gc/CriteriaTypeCode.gcwith all v2 codes - Runs UBL generator — regenerates all PHP classes, codelist enums, and registries from XSD schemas and Genericode files
The generator automatically merges v2 criterion codes into CriterionCode with a V2_ prefix and injects the CriterionCodeMethods trait for v2↔v4 conversion.
Options
| Option | Description |
|---|---|
--force, -f |
Actually generate files (without this, dry-run only) |
--codelists-only |
Only regenerate codelist enums (skip class generation) |
--mapping-only |
Only regenerate v2→v4 mapping files (skip UBL generator) |
Example output
Multi-version support
The generated CriterionCode enum contains both v4 short codes (crime-org, corruption, ...) and v2 long-form codes prefixed with V2_ (CRITERION.EXCLUSION.CONVICTIONS.PARTICIPATION_IN_CRIMINAL_ORGANISATION, ...). This allows deserializing ESPD documents from both v2.x and v4.x without data loss:
Development
EU Legislation References
The ESPD form structure and criterion classification are defined by EU legislation:
| Document | Reference | Relevance |
|---|---|---|
| Commission Implementing Regulation (EU) 2016/7 | Standard form for the ESPD | Defines the 6-part form structure (Parts I–VI) with sections A–D, used by EspdPart enum and getPart()/getSection() |
| Directive 2014/24/EU | Public procurement directive | Art. 57: exclusion grounds (Parts III-A/B/C/D), Art. 58: selection criteria (Parts IV-A/B/C), Art. 62: quality/environment certificates (Part IV-D) |
| ESPD-EDM (OP-TED) | Exchange Data Model | Source of criterion taxonomy XML, Schematron validation rules, and Genericode codelists used by this library |
License
MIT - Copyright (c) 2026 Ceana Razvan