| description | Console commands provided by the FHIR bundle. |
|---|---|
| icon | terminal |
The bundle adds these commands to a Symfony application:
| Command | Description |
|---|---|
fhir:generate |
Generate canonical FHIR model classes from core packages |
fhir:generate-ig |
Generate typed IG extension/profile classes |
fhir:path:evaluate |
Evaluate a FHIRPath expression against FHIR data |
fhir:path:validate |
Validate FHIRPath expression syntax |
This page is task-oriented. For the exhaustive argument and option reference, see the Console Command Reference.
Run once when setting up a project or upgrading the FHIR version. The command takes no positional
version argument — the target version is derived from each --package.
# Generate R4 models
php bin/console fhir:generate --package=hl7.fhir.r4.core -vvv
# Generate R4B models
php bin/console fhir:generate --package=hl7.fhir.r4b.core -vvv
# Offline mode (use cached packages only, no network)
php bin/console fhir:generate --package=hl7.fhir.r4.core --offline -vvvA matching hl7.terminology.* package is prepended automatically when not supplied. Increase
verbosity with -v/-vvv to see per-class output and stack traces on failure.
{% hint style="warning" %}
fhir:generate writes into src/Component/Models/src/ (generated output). Do not hand-edit those
files; regenerate them with this command.
{% endhint %}
fhir:generate-ig generates typed PHP classes for a FHIR Implementation Guide — named extension
subclasses and resource profile subclasses — into a namespace isolated from the base models.
The recommended approach is to configure packages under fhir.ig so the command needs no arguments
in CI or deploy scripts:
# config/packages/fhir.yaml
fhir:
ig:
namespace: 'App\FHIR\IG'
output_directory: '%kernel.project_dir%/src/FHIRIG'
offline: false
packages:
- hl7.fhir.us.coreThen run with no arguments:
php bin/console fhir:generate-igThe --package option overrides fhir.ig.packages entirely when supplied — useful for one-off
generation or CI pipelines. List dependent IGs after their dependencies:
# Single IG
php bin/console fhir:generate-ig --package=hl7.fhir.us.core
# Pin a specific version
php bin/console fhir:generate-ig --package=hl7.fhir.us.core#6.1.0
# Multi-level chain (AU Base before AU Core) — order matters
php bin/console fhir:generate-ig \
--package=hl7.fhir.au.base#1.0.0 \
--package=hl7.fhir.au.core#1.0.0Add the generated directory to your composer.json autoloader and run composer dump-autoload:
"autoload": {
"psr-4": {
"App\\FHIR\\IG\\": "src/FHIRIG/"
}
}# Evaluate against a null context
php bin/console fhir:path:evaluate "5 + 3"
# Evaluate against a JSON file
php bin/console fhir:path:evaluate "Patient.name.given" patient.json
# Output formats
php bin/console fhir:path:evaluate "name.given" patient.json --format=json --pretty
php bin/console fhir:path:evaluate "name.given" patient.json --format=count
# Show cache statistics
php bin/console fhir:path:evaluate "name" patient.json -vWhen data is an existing file path it must resolve within the current working directory
(path-traversal guard); otherwise the value is treated as an inline JSON string.
php bin/console fhir:path:validate "name.where(use = 'official').given.first()"Returns exit code 0 for valid syntax, 1 for invalid. Run with -v to print the compiled
expression on success or error details on failure.
See Code Generation and FHIRPath for the underlying behavior, and the Console Command Reference for full options.