A PHP library monorepo for working with FHIR (Fast Healthcare Interoperability Resources). This monorepo contains multiple standalone packages that can be used independently or together:
- FHIR Code Generation: Generate PHP model classes from FHIR Structure Definitions
- FHIR Serialization: JSON/XML serialization and deserialization
- FHIRPath: Expression evaluator for FHIRPath 2.0
- FHIR Models: Pre-generated FHIR model classes (R4, R4B, R5)
- FHIR Bundle: Symfony integration bundle
Install individual components in your project:
# For Symfony applications - includes console commands
composer require ardenexal/fhir-bundle
# For code generation
composer require ardenexal/fhir-code-generation
# For serialization
composer require ardenexal/fhir-serialization
# For FHIRPath evaluation
composer require ardenexal/fhir-path
# For pre-generated models
composer require ardenexal/fhir-modelsClone and develop on this monorepo:
git clone https://github.com/Ardenexal/php-fhir-tools.git
cd php-fhir-tools
composer installIf you've installed ardenexal/fhir-bundle in your Symfony application:
# Generate FHIR models
php bin/console fhir:generate --package=hl7.fhir.r4.core -vvv
# Generate typed classes for an Implementation Guide
php bin/console fhir:generate-ig --package=hl7.fhir.us.core
# Evaluate FHIRPath expressions
php bin/console fhir:path:evaluate "5 + 3"
# Against a JSON file
php bin/console fhir:path:evaluate "Patient.name.given" patient.json
# Output as JSON
php bin/console fhir:path:evaluate "name" patient.json --format=json --prettyuse Ardenexal\FHIRTools\Component\Serialization\FHIRSerializationService;
// Serialize to JSON
$json = $service->serializeToJson($patient);
// Deserialize from JSON
$patient = $service->deserializeFromJson($json, FHIRPatient::class);
// Auto-detect format (JSON or XML)
$resource = $service->deserialize($data);src/
├── Bundle/FHIRBundle/ # Symfony Bundle integration and console commands
├── Component/
│ ├── CodeGeneration/src/ # FHIR model class generation from Structure Definitions
│ ├── Serialization/src/ # FHIR JSON/XML serialization and deserialization
│ ├── Models/src/ # Generated FHIR model classes (R4, R4B, R5)
│ └── FHIRPath/src/ # FHIRPath 2.0 expression evaluator
Each component has its own README with detailed documentation:
- FHIRBundle — Symfony integration and console commands
- CodeGeneration — Model generation from FHIR packages
- Serialization — JSON/XML serialization
- FHIRPath — FHIRPath expression evaluation
- Models — Generated FHIR model classes
This is a library monorepo. Each component can be installed and used independently:
| Package | Description | Composer Install |
|---|---|---|
ardenexal/fhir-bundle |
Symfony Bundle with console commands | composer require ardenexal/fhir-bundle |
ardenexal/fhir-code-generation |
Generate PHP from FHIR definitions | composer require ardenexal/fhir-code-generation |
ardenexal/fhir-serialization |
JSON/XML serialization | composer require ardenexal/fhir-serialization |
ardenexal/fhir-path |
FHIRPath expression evaluator | composer require ardenexal/fhir-path |
ardenexal/fhir-models |
Pre-generated FHIR models | composer require ardenexal/fhir-models |
# Fix code style (PSR-12 via Laravel Pint)
composer lint
# Static analysis (PHPStan level 8)
composer phpstan
# Run all tests
composer test
# Run specific test suites
composer test-unit
composer test-integration
composer test-fhir
# Full quality check (lint + phpstan + test)
composer quality:allcomposer quality:bundle
composer quality:codegen
composer quality:serialization
composer quality:fhir-pathWhen you install ardenexal/fhir-bundle in your Symfony application, you get these console commands:
| Command | Description |
|---|---|
fhir:generate |
Generate PHP model classes from FHIR packages (R4, R4B, R5) |
fhir:generate-ig |
Generate typed extension and profile classes for FHIR IGs |
fhir:path:evaluate |
Evaluate a FHIRPath expression against FHIR data |
fhir:path:validate |
Validate FHIRPath expression syntax |
Note: These commands are only available when using the FHIR Bundle in a Symfony application. This monorepo is a library, not an application.
See CONTRIBUTING.md for development setup, coding standards, and contribution guidelines.
This project is licensed under the MIT License — see the LICENSE file for details.