PHPackages                             dcarbone/php-fhir - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. dcarbone/php-fhir

ActiveLibrary[API Development](/categories/api)

dcarbone/php-fhir
=================

Tools for creating PHP classes from the HL7 FHIR Specification

v4.1.1(3w ago)149296.2k↓77.8%43[3 issues](https://github.com/dcarbone/php-fhir/issues)[1 PRs](https://github.com/dcarbone/php-fhir/pulls)1Apache-2.0PHPPHP ^8.1CI passing

Since Jan 24Pushed 1w ago12 watchersCompare

[ Source](https://github.com/dcarbone/php-fhir)[ Packagist](https://packagist.org/packages/dcarbone/php-fhir)[ Docs](https://github.com/dcarbone/php-fhir)[ GitHub Sponsors](https://github.com/dcarbone)[ Fund](https://ko-fi.com/dcarbone)[ RSS](/packages/dcarbone-php-fhir/feed)WikiDiscussions main Synced 2d ago

READMEChangelog (10)Dependencies (15)Versions (76)Used By (1)

php-fhir
========

[](#php-fhir)

**Tools for generating PHP classes from the [HL7 FHIR](https://hl7.org/fhir/) specification.**

php-fhir reads the official FHIR XSD schema files and produces a fully-typed PHP library — complete with models for every FHIR type, JSON &amp; XML (de)serialization, validation, and a ready-to-use FHIR REST client.

---

🚀 Just Want the Generated Code?
-------------------------------

[](#-just-want-the-generated-code)

If you don't need to customise the generation process and just want usable FHIR models in your PHP project, grab the pre-built package:

**➡️ [dcarbone/php-fhir-generated](https://github.com/dcarbone/php-fhir-generated)**

---

📖 Documentation
---------------

[](#-documentation)

Full documentation is maintained on the **[project wiki](https://github.com/dcarbone/php-fhir/wiki)**:

PageDescription[Getting Started](https://github.com/dcarbone/php-fhir/wiki/Getting-Started)Prerequisites, installation, and downloading FHIR schemas[CLI Usage](https://github.com/dcarbone/php-fhir/wiki/CLI-Usage)Running the generator from the command line[Configuration Reference](https://github.com/dcarbone/php-fhir/wiki/Configuration-Reference)All `Config` and `VersionConfig` options[Architecture](https://github.com/dcarbone/php-fhir/wiki/Architecture)How the generator pipeline works internally[Generated Code](https://github.com/dcarbone/php-fhir/wiki/Generated-Code)Understanding the output: namespaces, types, client, encoding[Testing](https://github.com/dcarbone/php-fhir/wiki/Testing)Running tests on the generator and on generated code[Contributing](https://github.com/dcarbone/php-fhir/wiki/Contributing)Developer workflow and code-style notes---

Support Matrix
--------------

[](#support-matrix)

PHPFHIR VersionPHP VersionsFHIR VersionsSupportedv4&gt;= 8.1DSTU1, DSTU2, STU3, R4, R4B, R5, R6 (pre-release)**Yes**v3&gt;= 8.1, &lt; 8.5DSTU1, DSTU2, STU3, R4, R4B, R5Nov25.4–7.4DSTU1, DSTU2, STU3, R4No---

Requirements
------------

[](#requirements)

- **PHP** 8.1 or newer
- **Composer** — [getcomposer.org](https://getcomposer.org/)
- **PHP extensions:** `ctype`, `curl`, `dom`, `json`, `libxml`, `simplexml`, `xmlreader`, `xmlwriter`
- **FHIR schemas:** extracted XSD bundles for each version you wish to generate (see the [Getting Started](https://github.com/dcarbone/php-fhir/wiki/Getting-Started) wiki page for download links)

---

Quick Start
-----------

[](#quick-start)

### 1. Install

[](#1-install)

```
# Standalone
git clone https://github.com/dcarbone/php-fhir.git
cd php-fhir && composer install

# — or as a Composer dependency in your own project —
composer require dcarbone/php-fhir
```

### 2. Download FHIR Schemas

[](#2-download-fhir-schemas)

```
mkdir -p fhir-schemas/R4
curl -Lo fhir-schemas/R4.zip https://hl7.org/fhir/R4/fhir-codegen-xsd.zip
unzip fhir-schemas/R4.zip -d fhir-schemas/R4
```

### 3. Generate

[](#3-generate)

**Option A — PHP script:**

```
