romeldev / php-fhir
PHP 7.4-compatible FHIR R4 classes generated from official HL7 XSD schemas
dev-main
2026-06-30 20:11 UTC
Requires
- php: >=7.4
- ext-dom: *
- ext-json: *
- ext-libxml: *
- ext-simplexml: *
- ext-xmlreader: *
- ext-xmlwriter: *
This package is auto-updated.
Last update: 2026-06-30 20:11:40 UTC
README
PHP 7.4-compatible FHIR R4 classes generated from official HL7 XSD schemas.
Installation
composer require romeldev/php-fhir
Usage
<?php require 'vendor/autoload.php'; use RomelDev\FHIR\R4\FHIRResource\FHIRDomainResource\FHIRPatient; use RomelDev\FHIR\R4\FHIRElement\FHIRHumanName; use RomelDev\FHIR\R4\FHIRElement\FHIRString; use RomelDev\FHIR\R4\FHIRElement\FHIRDate; $patient = new FHIRPatient(); $patient->setActive(true); $patient->setBirthDate(new FHIRDate('1990-01-15')); $name = new FHIRHumanName(); $name->setFamily(new FHIRString('Doe')); $name->addGiven(new FHIRString('John')); $patient->addName($name); echo json_encode($patient, JSON_PRETTY_PRINT);
Development
Prerequisites
- Docker & Docker Compose
Build the Docker image
docker compose build
Install generator dependencies
docker compose run --rm builder composer install -d generator
Download FHIR R4 schemas
docker compose run --rm builder php download-schemas.php
Generate library classes
docker compose run --rm builder php build.php
Add another FHIR version (e.g., R5)
- Add entry in
build/config.php docker compose run --rm builder php download-schemas.php R5docker compose run --rm builder php build.php R5- Commit
License
Apache License 2.0