-
-
Notifications
You must be signed in to change notification settings - Fork 42
Builder Configuration
These are the configuration options available when generating code using the Builder
Option | Type | Description |
---|---|---|
libraryPath |
string | (Required) Output directory for generated Library code. |
versions |
iterable of assoc. arrays | (Required) Configuration of each version you wish to generate. See Version Configuration for details. |
libraryNamespacePrefix |
string | (Optional) Namespace prefix for the generated library. |
librarySchemaLibxmlOpts |
integer | (Optional) Option mask of libxml options to use when parsing version schema .xsd files. |
testsPath |
string | (Optional) Output directory for generated Test code. Leaving this blank will disable test generation. |
testsNamespacePrefix |
string | (Optional) Namespace prefix for generated tests. |
logger |
\Psr\Log\LoggerInterface |
(Optional) Instance of \Psr\Log\LoggerInterface logger to use. If not defined, logging will be silenced. |
The versions
configuration key must be defined as either an array of associative arrays, or an array of objects.
These options are used when generating code for a particular FHIR version.
Option | Type | Description |
---|---|---|
name |
string | (Required) Unique name for version. By default this is also used as the version's namespace, but you may override this with the namespace option. |
schemaPath |
string | (Required) Fully qualified path to directory containing version schema .xsd files. The generator does NOT recurse into sub-directories. |
namespace |
string | (Optional) Namespace for version. This is nested under the $rootNamespace\\Versions . If not set, name value will be used if it is a valid PHP namespace key. |
defaultConfig |
assoc. array | (Optional) Default configuration options for the generated code. These options may be overridden at runtime. |
These options are set as the defaults for a particular generated version's code. They may be overridden at runtime when using the code.
Option | Type | Description |
---|---|---|
unserializeConfig |
assoc. array | (Optional) Configuration to use when unserializing from JSON or XML into modeled types. |
serializeConfig |
assoc. array | (Optional) Configuration to use when serializing from modeled types into JSON or XML. |
These are the default options that the generated code for a given version will use when unserializing from XML or JSON. You may override these values at runtime.
Option | Type | Description |
---|---|---|
libxmlOpts |
integer | (Optional) Option mask of libxml options to use when unserializing types from XML. Mutually exclusive with libxmlOptMask . |
libxmlOptMask |
string | (Optional) String value of libxml options. Can result in "prettier" generated output. Mutually exclusive with libxmlOpts . |
jsonDecodeMaxDepth |
integer | (Optional) Maximum depth to decode JSON objects. Defaults to language default. |
jsonDecodeOpts |
integer | (Optional) Option mask of json options to use when decoding JSON. Mutually exclusive with jsonDecodeOptMask . |
jsonDecodeOptMask |
string | (Optional) String value of json options. Can result in "prettier" generated output. Mutually exclusive with jsonDecodeOpts . |
These options are set as the defaults for a particular generated version's code. They may be overridden at runtime when using the code.
Option | Type | Description |
---|---|---|
overrideSourceXMLNS |
boolean | (Optional) If true, will override the XMLNS parsed from the source when unserializing XML with the value provided to rootXMLNS . |
rootXMLNS |
string | (Optional) XMLNS value to use when serializing to XML. Will always be used if source did not contain XMLNS, or if overrideSourceXMLNS is true. Required if overrideSourceXMLNS is true. |
xhtmlLibOpts |
integer | (Optional) Option mask of libxml options to use when encoding fields with the XHTML type. |
There are two primary ways to construct a Config object:
<?php
use DCarbone\PHPFHIR\Config;
use DCarbone\PHPFHIR\Config\VersionConfig;
$config = new Config(
libraryPath: 'destination path for generated library code',
libraryNamespacePrefix: '\\Your\\Desired\\Library\\Namespace',
versions: [
[
'name' => 'R4',
'schemaPath' => 'path to extracted .xsd R4 version schema files',
],
new VersionConfig(
name: 'R5',
schemaPath: 'path to extracted .xsd R5 version schema files',
),
]
);
You can also construct a Config
instance from a map:
<?php
use DCarbone\PHPFHIR\Config;
$configMap = [
'libraryPath' => 'destination path for generated library code',
'libraryNamespacePrefix' => '\\Your\\Desired\\Library\\Namespace',
'versions' => [
[
'name' => 'R4',
'schemaPath' => 'path to extracted .xsd R4 version schema files',
],
[
'name' => 'R5',
'schemaPath' => 'path to extracted .xsd R5 version schema files',
],
],
];
$conifg = Config::fromArray($configMap);