familytree365 / php-gedcom
A GEDCOM file parser (read + write) for PHP 8.0+
Fund package maintenance!
familytree365
Installs: 9 580
Dependents: 0
Suggesters: 0
Security: 0
Stars: 24
Watchers: 2
Forks: 46
Open Issues: 5
Requires
- php: >=8.0
Requires (Dev)
- phpunit/phpunit: 9.*
- rector/rector: ^0.11.49
- squizlabs/php_codesniffer: 3.6.*
- dev-master
- v1.4.10
- v1.4.9
- v1.4.8
- v1.4.7
- v1.4.6
- v1.4.5
- v1.4.4
- v1.4.3
- v1.4.2
- v1.4.1
- v1.4
- v1.3.17
- v1.3.16
- v1.3.15
- v1.3.14
- v1.3.13
- v1.3.12
- v1.3.11
- v1.3.10
- v1.3.9
- v1.3.8
- v1.3.7
- v1.3.6
- v1.3.5
- v1.3.4
- v1.3.3
- v1.3.2
- v1.3.1
- v1.3.0
- v1.2.7
- v1.2.6
- v1.2.5
- v1.2.4
- v1.2.3
- v1.2.2
- v1.2.1
- v1.2.0
- v1.1.3
- v1.1.2
- v1.1.1
- v1.1.0
- 1.0.5
- 1.0.4
- 1.0.3
- 1.0.2
- 1.0.1
- 1.0.0
- dev-main
This package is auto-updated.
Last update: 2024-11-15 00:33:05 UTC
README
Requirements
- php-gedcom 1.0+ requires PHP 8.0 (or later).
Installation
There are two ways of installing php-gedcom.
Composer
To install php-gedcom in your project using composer, simply add the following require line to your project's composer.json
file:
{
"require": {
"familytree365/php-gedcom": "1.0.*"
}
}
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); } });
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) { echo $individual->getId() . ': ' . current($individual->getName())->getSurn() . ', ' . current($indi->$individual())->getGivn(); }