PHPackages                             liberu-genealogy/php-gedcom - 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. [Parsing &amp; Serialization](/categories/parsing)
4. /
5. liberu-genealogy/php-gedcom

ActiveLibrary[Parsing &amp; Serialization](/categories/parsing)

liberu-genealogy/php-gedcom
===========================

A GEDCOM file parser (read + write) for PHP 8.4+

v4.2.0(2mo ago)755.6k↓50%47[1 issues](https://github.com/liberu-genealogy/php-gedcom/issues)[1 PRs](https://github.com/liberu-genealogy/php-gedcom/pulls)2MITPHPPHP &gt;=8.3CI passing

Since Jan 29Pushed 2mo ago3 watchersCompare

[ Source](https://github.com/liberu-genealogy/php-gedcom)[ Packagist](https://packagist.org/packages/liberu-genealogy/php-gedcom)[ Docs](http://github.com/familytree365/php-gedcom)[ GitHub Sponsors](https://github.com/liberu-genealogy)[ RSS](/packages/liberu-genealogy-php-gedcom/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (10)Dependencies (5)Versions (115)Used By (2)

php-gedcom
==========

[](#php-gedcom)

[![Latest Stable Version](https://camo.githubusercontent.com/f7dddaf69a33536dd222edb7c55078493d26d83e3a54dffbb7dc24720cda0823/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f72656c656173652f6c69626572752d67656e65616c6f67792f7068702d676564636f6d2e737667)](https://camo.githubusercontent.com/f7dddaf69a33536dd222edb7c55078493d26d83e3a54dffbb7dc24720cda0823/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f72656c656173652f6c69626572752d67656e65616c6f67792f7068702d676564636f6d2e737667)[![Tests](https://github.com/liberu-genealogy/php-gedcom/actions/workflows/run-tests.yml/badge.svg)](https://github.com/liberu-genealogy/php-gedcom/actions/workflows/run-tests.yml)

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

[](#requirements)

- php-gedcom 2.0+ requires PHP 8.3 (or later). GEDCOM 5.5.1 only
- php-gedcom 3.0+ requires PHP 8.4 (or later). GEDCOM 5.5.1 only
- php-gedcom 4.0+ requires PHP 8.4 (or later). GEDCOM 5.5.1, GEDCOM 7.0 and GEDCOM X with performance optimizations

Installation
------------

[](#installation)

There are two ways of installing php-gedcom.

### Composer

[](#composer)

To install php-gedcom in your project using composer, simply add the following require line to your project's `composer.json` file:

```
{
    "require": {
        "liberu-genealogy/php-gedcom": "2.0.*"
    }
}

```

### Download and \_\_autoload

[](#download-and-__autoload)

If you are not using composer, you can download an archive of the source from GitHub and extract it into your project. You'll need to setup an autoloader for the files, unless you go through the painstaking process if requiring all the needed files one-by-one. Something like the following should suffice:

```
spl_autoload_register(function ($class) {
    $pathToGedcom = __DIR__ . '/library/'; // TODO FIXME

    if (!substr(ltrim($class, '\\'), 0, 7) == 'Gedcom\\') {
        return;
    }

    $class = str_replace('\\', DIRECTORY_SEPARATOR, $class) . '.php';
    if (file_exists($pathToGedcom . $class)) {
        require_once($pathToGedcom . $class);
    }
});
```

Performance Optimizations (PHP 8.4+)
------------------------------------

[](#performance-optimizations-php-84)

php-gedcom 4.0+ includes significant performance improvements leveraging PHP 8.4 features:

### Key Optimizations

[](#key-optimizations)

- **Streaming Parsers**: Automatic streaming for large files (&gt;100MB) to reduce memory usage
- **Intelligent Caching**: LRU cache with file modification tracking and automatic invalidation
- **Property Hooks**: Lazy initialization of parsers and generators using PHP 8.4 property hooks
- **Optimized JSON Processing**: Enhanced JSON parsing with streaming support for large Gedcom X files
- **Memory Efficiency**: Reduced memory footprint through optimized data structures

### Performance Features

[](#performance-features)

- **Caching System**: Automatic caching of parsed files with configurable TTL and size limits
- **Large File Support**: Streaming parsers handle files of any size without memory exhaustion
- **Format Detection**: Fast file format detection with content analysis
- **Batch Operations**: Optimized array operations using PHP 8.4 features

### Benchmarking

[](#benchmarking)

Run performance benchmarks to measure improvements:

```
# Basic benchmark
php examples/cli/performance-benchmark.php sample.ged

# Full benchmark with streaming and report
php examples/cli/performance-benchmark.php large.ged --streaming --report

# Save baseline for comparison
php examples/cli/performance-benchmark.php test.ged --baseline

# Compare with baseline
php examples/cli/performance-benchmark.php test.ged --compare
```

### Cache Configuration

[](#cache-configuration)

```
use Gedcom\GedcomResource;

// Enable caching with custom configuration
$resource = new GedcomResource(
    cacheEnabled: true,
    cacheConfig: [
        'memory_items' => 2000,           // Max items in memory cache
        'cache_dir' => '/tmp/gedcom',     // Cache directory
        'ttl' => 7200                     // Cache TTL in seconds
    ]
);

// Get cache statistics
$stats = $resource->getCacheStats();
echo "Memory items: " . $stats['memory_items'] . "\n";

// Clear cache when needed
$resource->clearCache();
```

### GEDCOM Format Support

[](#gedcom-format-support)

php-gedcom 4.0+ supports both GEDCOM 5.5.1 and GEDCOM 7.0 formats. The library automatically detects the version when parsing and can write to either format.

#### Parsing GEDCOM Files

[](#parsing-gedcom-files)

The parser automatically handles both GEDCOM 5.5.1 and 7.0 formats:

```
$parser = new \Gedcom\Parser();

// Parse a GEDCOM 5.5.1 file
$gedcom551 = $parser->parse('family_tree_551.ged');

// Parse a GEDCOM 7.0 file
$gedcom70 = $parser->parse('family_tree_70.ged');

// Check the version
$head = $gedcom70->getHead();
$gedc = $head->getGedc();
$version = $gedc->getVersion(); // Returns "7.0" or "5.5.1"
```

#### Writing GEDCOM Files

[](#writing-gedcom-files)

You can export to either format by specifying the format constant:

```
use Gedcom\Writer;

// Write as GEDCOM 5.5.1 (default)
$output551 = Writer::convert($gedcom, Writer::GEDCOM55);
file_put_contents('output_551.ged', $output551);

// Write as GEDCOM 7.0
$output70 = Writer::convert($gedcom, Writer::GEDCOM70);
file_put_contents('output_70.ged', $output70);
```

#### Version-Specific Features

[](#version-specific-features)

The library handles version-specific features automatically:

FeatureGEDCOM 5.5.1GEDCOM 7.0Unique Identifier`_UID` (custom tag)`UID` (standard tag)Source Data DateNot supported`DATE` subfieldSource Data TextNot supported`TEXT` subfieldWhen writing to a specific format:

- **GEDCOM 5.5.1**: Outputs `_UID` tags for unique identifiers
- **GEDCOM 7.0**: Outputs `UID` tags for unique identifiers

The parser reads both tag types, ensuring compatibility when converting between versions.

### Usage

[](#usage)

To parse a GEDCOM file and load it into a collection of PHP Objects, simply instantiate a new Parser object and pass it the file name to parse. The resulting Gedcom object will contain all the information stored within the supplied GEDCOM file:

```
$parser = new \Gedcom\Parser();
$gedcom = $parser->parse('tmp.ged');

foreach ($gedcom->getIndi() as $individual) {
    $names = $individual->getName();
    if (!empty($names)) {
        $name = reset($names); // Get the first name object from the array
        echo $individual->getId() . ': ' . $name->getSurn() . ', ' . $name->getGivn() . PHP_EOL;
    }
}
```

Contributing
------------

[](#contributing)

Pull requests are welcome, as are issues.

License
-------

[](#license)

MIT License (see License.md). This means you must retain the copyright and permission notice is all copies, or substantial portions of this software.

Contributors
------------

[](#contributors)

[ ![](https://camo.githubusercontent.com/00af225e8d92783f8e0769fa27b0c24ed5a0eff95c1dc0c2e962056396a28c8e/68747470733a2f2f636f6e747269622e726f636b732f696d6167653f7265706f3d6c69626572752d67656e65616c6f67792f7068702d676564636f6d)](https://github.com/liberu-genealogy/php-gedcom/graphs/contributors)

###  Health Score

66

—

FairBetter than 99% of packages

Maintenance83

Actively maintained with recent releases

Popularity41

Moderate usage in the ecosystem

Community31

Small or concentrated contributor base

Maturity95

Battle-tested with a long release history

 Bus Factor2

2 contributors hold 50%+ of commits

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~73 days

Recently: every ~40 days

Total

66

Last Release

85d ago

Major Versions

v1.4.10 → v2.0.02024-03-12

v2.2.0 → v3.0.02025-03-22

v3.2.3 → v4.0.02025-09-07

PHP version history (5 changes)1.0.0PHP &gt;=5.3

v1.1.1PHP &gt;=7.3

v1.4PHP &gt;=8.0

v2.0.0PHP &gt;=8.3

v3.0.0PHP &gt;=8.4

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/179251?v=4)[Curtis Delicata](/maintainers/curtisdelicata)[@curtisdelicata](https://github.com/curtisdelicata)

---

Top Contributors

[![curtisdelicata](https://avatars.githubusercontent.com/u/179251?v=4)](https://github.com/curtisdelicata "curtisdelicata (155 commits)")[![sweep-ai-deprecated[bot]](https://avatars.githubusercontent.com/in/307814?v=4)](https://github.com/sweep-ai-deprecated[bot] "sweep-ai-deprecated[bot] (87 commits)")[![mrkrstphr](https://avatars.githubusercontent.com/u/164472?v=4)](https://github.com/mrkrstphr "mrkrstphr (33 commits)")[![jyyblue](https://avatars.githubusercontent.com/u/36446990?v=4)](https://github.com/jyyblue "jyyblue (23 commits)")[![Copilot](https://avatars.githubusercontent.com/in/1143301?v=4)](https://github.com/Copilot "Copilot (19 commits)")[![albarin](https://avatars.githubusercontent.com/u/186112?v=4)](https://github.com/albarin "albarin (15 commits)")[![Jefferson49](https://avatars.githubusercontent.com/u/81484983?v=4)](https://github.com/Jefferson49 "Jefferson49 (11 commits)")[![JoshKisb](https://avatars.githubusercontent.com/u/7253780?v=4)](https://github.com/JoshKisb "JoshKisb (10 commits)")[![heru0502](https://avatars.githubusercontent.com/u/32084622?v=4)](https://github.com/heru0502 "heru0502 (8 commits)")[![juliolopez78](https://avatars.githubusercontent.com/u/5769504?v=4)](https://github.com/juliolopez78 "juliolopez78 (6 commits)")[![juliengeneanet](https://avatars.githubusercontent.com/u/20107278?v=4)](https://github.com/juliengeneanet "juliengeneanet (5 commits)")[![delicatacurtis](https://avatars.githubusercontent.com/u/247246500?v=4)](https://github.com/delicatacurtis "delicatacurtis (5 commits)")[![skypal](https://avatars.githubusercontent.com/u/27696696?v=4)](https://github.com/skypal "skypal (4 commits)")[![xeanu](https://avatars.githubusercontent.com/u/82022184?v=4)](https://github.com/xeanu "xeanu (2 commits)")[![stuporglue](https://avatars.githubusercontent.com/u/16576?v=4)](https://github.com/stuporglue "stuporglue (2 commits)")[![tlesseli](https://avatars.githubusercontent.com/u/2758167?v=4)](https://github.com/tlesseli "tlesseli (2 commits)")[![webstar1027](https://avatars.githubusercontent.com/u/32419290?v=4)](https://github.com/webstar1027 "webstar1027 (2 commits)")[![litui](https://avatars.githubusercontent.com/u/273040?v=4)](https://github.com/litui "litui (1 commits)")[![WorkingDevel](https://avatars.githubusercontent.com/u/774381?v=4)](https://github.com/WorkingDevel "WorkingDevel (1 commits)")[![vfftech](https://avatars.githubusercontent.com/u/67114434?v=4)](https://github.com/vfftech "vfftech (1 commits)")

---

Tags

gedcomgedcom-parsergedcom-parsinggedcomxlaravellaravel10phpphp8parsergedcomgenealogy

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan, Rector

Code StylePHP\_CodeSniffer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/liberu-genealogy-php-gedcom/health.svg)

```
[![Health](https://phpackages.com/badges/liberu-genealogy-php-gedcom/health.svg)](https://phpackages.com/packages/liberu-genealogy-php-gedcom)
```

###  Alternatives

[nikic/php-parser

A PHP parser written in PHP

17.4k902.6M1.8k](/packages/nikic-php-parser)[doctrine/lexer

PHP Doctrine Lexer parser library that can be used in Top-Down, Recursive Descent Parsers.

11.2k910.8M118](/packages/doctrine-lexer)[erusev/parsedown

Parser for Markdown.

15.0k151.8M732](/packages/erusev-parsedown)[league/commonmark

Highly-extensible PHP Markdown parser which fully supports the CommonMark spec and GitHub-Flavored Markdown (GFM)

2.9k404.0M702](/packages/league-commonmark)[masterminds/html5

An HTML5 parser and serializer.

1.8k242.8M229](/packages/masterminds-html5)[sabberworm/php-css-parser

Parser for CSS Files written in PHP

1.8k191.2M65](/packages/sabberworm-php-css-parser)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
