{"id":19606860,"url":"https://github.com/chesszebra/portable-game-notation","last_synced_at":"2025-06-30T09:33:59.828Z","repository":{"id":56975609,"uuid":"106614594","full_name":"chesszebra/portable-game-notation","owner":"chesszebra","description":"A PHP library to parse and write chess games in the portable game notation (PGN) format.","archived":false,"fork":false,"pushed_at":"2022-02-22T21:33:00.000Z","size":42,"stargazers_count":2,"open_issues_count":0,"forks_count":3,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-05T03:01:51.654Z","etag":null,"topics":["chess","lexer","parser","pgn","php","portable-game-notation","reader","writer"],"latest_commit_sha":null,"homepage":"https://chesszebra.com","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/chesszebra.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-10-11T22:08:36.000Z","updated_at":"2025-01-22T02:32:31.000Z","dependencies_parsed_at":"2022-08-21T07:10:14.947Z","dependency_job_id":null,"html_url":"https://github.com/chesszebra/portable-game-notation","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chesszebra%2Fportable-game-notation","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chesszebra%2Fportable-game-notation/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chesszebra%2Fportable-game-notation/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chesszebra%2Fportable-game-notation/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/chesszebra","download_url":"https://codeload.github.com/chesszebra/portable-game-notation/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251196422,"owners_count":21550950,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["chess","lexer","parser","pgn","php","portable-game-notation","reader","writer"],"created_at":"2024-11-11T10:07:26.055Z","updated_at":"2025-04-27T19:33:04.581Z","avatar_url":"https://github.com/chesszebra.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# portable-game-notation\n\n[![Latest Version on Packagist][ico-version]][link-packagist]\n[![Software License][ico-license]](LICENSE.md)\n[![Build Status][ico-travis]][link-travis]\n[![Coverage Status][ico-scrutinizer]][link-scrutinizer]\n[![Quality Score][ico-code-quality]][link-code-quality]\n[![Total Downloads][ico-downloads]][link-downloads]\n\nA PHP library to parse and write chess games in the portable game notation (PGN) format.\n\n## Installation\n\nVia composer\n\n```\ncomposer require chesszebra/portable-game-notation\n```\n\n## Usage\n\n### Reading\n\n#### From a string\n\nReading a single PGN game from a string:\n\n```php\nuse ChessZebra\\PortableGameNotation\\Reader\\StringReader;\n\n$reader = new StringReader('1. e4 e5');\n\n$tokenIterator = $reader-\u003eread();\n```\n\n#### From a stream\n\nReading a single PGN game from a stream:\n\n```php\nuse ChessZebra\\PortableGameNotation\\Reader\\StringReader;\n\n$reader = new StreamReader(fopen('games.pgn', 'r'));\n\n$tokenIterator = $reader-\u003eread();\n```\n\n### Writing\n\n#### To a string\n\nWriring a PGN game to a string:\n\n```php\nuse ChessZebra\\PortableGameNotation\\TokenIterator;\nuse ChessZebra\\PortableGameNotation\\Token\\StandardAlgebraicNotation;\nuse ChessZebra\\PortableGameNotation\\Writer\\StringWriter;\nuse ChessZebra\\StandardAlgebraicNotation\\Notation;\n\n$tokenIterator = new TokenIterator([\n    new MoveNumber(1),\n    new StandardAlgebraicNotation(new Notation('e4')),\n]);\n\n$writer = new StringWriter();\n$writer-\u003ewrite($tokenIterator);\n\n$pgn = $writer-\u003egetPgn();\n```\n\n#### To a stream\n\nWriring a PGN game to a stream:\n\n```php\nuse ChessZebra\\PortableGameNotation\\TokenIterator;\nuse ChessZebra\\PortableGameNotation\\Token\\StandardAlgebraicNotation;\nuse ChessZebra\\PortableGameNotation\\Writer\\Stream;\nuse ChessZebra\\StandardAlgebraicNotation\\Notation;\n\n$tokenIterator = new TokenIterator([\n    new MoveNumber(1),\n    new StandardAlgebraicNotation(new Notation('e4')),\n]);\n\n$writer = new Stream(fopen('game.pgn', 'w'));\n$writer-\u003ewrite($tokenIterator);\n```\n\n### Tokenizing games\n\n#### From a string\n\n```php\nuse ChessZebra\\PortableGameNotation\\Lexer\\StringLexer;\n\n$lexer = new StringLexer('1. e4');\n\n$token = $lexer-\u003egetNextToken();\n```\n\n#### From a resource\n\n```php\nuse ChessZebra\\PortableGameNotation\\Lexer\\StreamLexer;\n\n$lexer = new StreamLexer(fopen('my-games.pgn', 'r'));\n\n$token = $lexer-\u003egetNextToken();\n```\n\n## Contributing\n\nPlease see [CONTRIBUTING](CONTRIBUTING.md) and [CONDUCT](CONDUCT.md) for details.\n\n## Security\n\nIf you discover any security related issues, please report them via [HackerOne][link-hackerone].\n\n## License\n\nThe MIT License (MIT). Please see [License File](LICENSE.md) for more information.\n\n[ico-version]: https://img.shields.io/packagist/v/chesszebra/portable-game-notation.svg?style=flat-square\n[ico-license]: https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square\n[ico-travis]: https://img.shields.io/travis/chesszebra/portable-game-notation/master.svg?style=flat-square\n[ico-scrutinizer]: https://img.shields.io/scrutinizer/coverage/g/chesszebra/portable-game-notation.svg?style=flat-square\n[ico-code-quality]: https://img.shields.io/scrutinizer/g/chesszebra/portable-game-notation.svg?style=flat-square\n[ico-downloads]: https://img.shields.io/packagist/dt/chesszebra/portable-game-notation.svg?style=flat-square\n\n[link-packagist]: https://packagist.org/packages/chesszebra/portable-game-notation\n[link-travis]: https://travis-ci.org/chesszebra/portable-game-notation\n[link-scrutinizer]: https://scrutinizer-ci.com/g/chesszebra/portable-game-notation/code-structure\n[link-code-quality]: https://scrutinizer-ci.com/g/chesszebra/portable-game-notation\n[link-downloads]: https://packagist.org/packages/chesszebra/portable-game-notation\n[link-contributors]: ../../contributors\n[link-hackerone]: https://hackerone.com/chesszebra\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchesszebra%2Fportable-game-notation","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fchesszebra%2Fportable-game-notation","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchesszebra%2Fportable-game-notation/lists"}