Gedcom
in package
Entry point for common tasks; the classes behind it can be injected directly.
Table of Contents
Methods
- convert() : ConversionResult
- Converts the document to another version; the document is not changed.
- convertFile() : LossReport
- Converts a file of any size record by record, writing the output as it goes: the same bytes and losses as {@see self::convert()} of the whole document, in memory that holds an index of the input rather than its tree.
- open() : IndexedDocument
- Opens a file for reading without its tree in memory: an index of the records, which are read from the file when asked for. A resource that cannot seek is copied to php://temp first (in memory up to 2 MB, then in a temporary file). A zip:// path is not copied: the entry is read forward and opened again to go back, which decompresses it from the start; read its records in order (as {@see self::convertFile()} does), not at random.
- parse() : Document
- read() : Document
- readGedzip() : Archive
- Reads a GEDZIP archive (.gdz): gedcom.ged as a document, the media as streams on demand.
- serialize() : string
- stream() : RecordStream
- Reads a file one record at a time, in memory that does not grow with the file.
- validate() : ValidationReport
- Checks the document against the profile of its version; the document is not changed. An indexed file ({@see self::open()}) is checked record by record, without its tree in memory.
- write() : void
- writeGedzip() : void
- Writes a GEDZIP archive: a 7.0 document as gedcom.ged, and the media under the names its FILE references use. Needs ext-zip.
Methods
convert()
Converts the document to another version; the document is not changed.
public
static convert(Document $document, Version $to[, ConvertOptions $options = new ConvertOptions() ]) : ConversionResult
Parameters
- $document : Document
- $to : Version
- $options : ConvertOptions = new ConvertOptions()
Tags
Return values
ConversionResultconvertFile()
Converts a file of any size record by record, writing the output as it goes: the same bytes and losses as {@see self::convert()} of the whole document, in memory that holds an index of the input rather than its tree.
public
static convertFile(string|resource $input, string|resource $output, Version $to[, ConvertOptions $options = new ConvertOptions() ][, ReadOptions $read = new ReadOptions() ]) : LossReport
Parameters
- $input : string|resource
-
a path, or an open handle read from its current position (not closed)
- $output : string|resource
-
a path, or an open handle written from its current position (not closed)
- $to : Version
- $options : ConvertOptions = new ConvertOptions()
- $read : ReadOptions = new ReadOptions()
Tags
Return values
LossReportopen()
Opens a file for reading without its tree in memory: an index of the records, which are read from the file when asked for. A resource that cannot seek is copied to php://temp first (in memory up to 2 MB, then in a temporary file). A zip:// path is not copied: the entry is read forward and opened again to go back, which decompresses it from the start; read its records in order (as {@see self::convertFile()} does), not at random.
public
static open(string|resource $source[, ReadOptions $options = new ReadOptions() ]) : IndexedDocument
Parameters
- $source : string|resource
-
a path, or an open handle read from its current position (not closed)
- $options : ReadOptions = new ReadOptions()
Tags
Return values
IndexedDocumentparse()
public
static parse(string $bytes[, ReadOptions $options = new ReadOptions() ]) : Document
Parameters
- $bytes : string
- $options : ReadOptions = new ReadOptions()
Tags
Return values
Documentread()
public
static read(string $path[, ReadOptions $options = new ReadOptions() ]) : Document
Parameters
- $path : string
- $options : ReadOptions = new ReadOptions()
Tags
Return values
DocumentreadGedzip()
Reads a GEDZIP archive (.gdz): gedcom.ged as a document, the media as streams on demand.
public
static readGedzip(string $path[, ReadOptions $options = new ReadOptions() ]) : Archive
Needs ext-zip.
Parameters
- $path : string
- $options : ReadOptions = new ReadOptions()
Tags
Return values
Archiveserialize()
public
static serialize(Document $document[, WriteOptions $options = new WriteOptions() ]) : string
Parameters
- $document : Document
- $options : WriteOptions = new WriteOptions()
Return values
stringstream()
Reads a file one record at a time, in memory that does not grow with the file.
public
static stream(string|resource $source[, ReadOptions $options = new ReadOptions() ]) : RecordStream
Parameters
- $source : string|resource
-
a path, or an open handle read from its current position (not closed)
- $options : ReadOptions = new ReadOptions()
Tags
Return values
RecordStreamvalidate()
Checks the document against the profile of its version; the document is not changed. An indexed file ({@see self::open()}) is checked record by record, without its tree in memory.
public
static validate(Document|IndexedDocument $document[, ValidationOptions $options = new ValidationOptions() ]) : ValidationReport
Parameters
- $document : Document|IndexedDocument
- $options : ValidationOptions = new ValidationOptions()
Return values
ValidationReportwrite()
public
static write(Document $document, string $path[, WriteOptions $options = new WriteOptions() ]) : void
Parameters
- $document : Document
- $path : string
- $options : WriteOptions = new WriteOptions()
writeGedzip()
Writes a GEDZIP archive: a 7.0 document as gedcom.ged, and the media under the names its FILE references use. Needs ext-zip.
public
static writeGedzip(Document $document, string $path[, array<string|int, string|resource> $media = [] ][, WriteOptions $options = new WriteOptions() ]) : void
Parameters
- $document : Document
- $path : string
- $media : array<string|int, string|resource> = []
-
entry name => a file to add, or a stream
- $options : WriteOptions = new WriteOptions()