2017 © Pedro Peláez
 

library portable-game-notation

A PHP library to parse and write chess games in the portable game notation (PGN) format.

image

chesszebra/portable-game-notation

A PHP library to parse and write chess games in the portable game notation (PGN) format.

  • Wednesday, November 29, 2017
  • by waltertamboer
  • Repository
  • 1 Watchers
  • 0 Stars
  • 148 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 4 Versions
  • 16 % Grown

The README.md

portable-game-notation

Latest Version on Packagist ![Software License][ico-license] Build Status ![Coverage Status][ico-scrutinizer] Quality Score ![Total Downloads][ico-downloads], (*1)

A PHP library to parse and write chess games in the portable game notation (PGN) format., (*2)

Installation

Via composer, (*3)

composer require chesszebra/portable-game-notation

Usage

Reading

From a string

Reading a single PGN game from a string:, (*4)

use ChessZebra\PortableGameNotation\Reader\StringReader;

$reader = new StringReader('1. e4 e5');

$tokenIterator = $reader->read();

From a stream

Reading a single PGN game from a stream:, (*5)

use ChessZebra\PortableGameNotation\Reader\StringReader;

$reader = new StreamReader(fopen('games.pgn', 'r'));

$tokenIterator = $reader->read();

Writing

To a string

Wriring a PGN game to a string:, (*6)

use ChessZebra\PortableGameNotation\TokenIterator;
use ChessZebra\PortableGameNotation\Token\StandardAlgebraicNotation;
use ChessZebra\PortableGameNotation\Writer\StringWriter;
use ChessZebra\StandardAlgebraicNotation\Notation;

$tokenIterator = new TokenIterator([
    new MoveNumber(1),
    new StandardAlgebraicNotation(new Notation('e4')),
]);

$writer = new StringWriter();
$writer->write($tokenIterator);

$pgn = $writer->getPgn();

To a stream

Wriring a PGN game to a stream:, (*7)

use ChessZebra\PortableGameNotation\TokenIterator;
use ChessZebra\PortableGameNotation\Token\StandardAlgebraicNotation;
use ChessZebra\PortableGameNotation\Writer\Stream;
use ChessZebra\StandardAlgebraicNotation\Notation;

$tokenIterator = new TokenIterator([
    new MoveNumber(1),
    new StandardAlgebraicNotation(new Notation('e4')),
]);

$writer = new Stream(fopen('game.pgn', 'w'));
$writer->write($tokenIterator);

Tokenizing games

From a string

use ChessZebra\PortableGameNotation\Lexer\StringLexer;

$lexer = new StringLexer('1. e4');

$token = $lexer->getNextToken();

From a resource

use ChessZebra\PortableGameNotation\Lexer\StreamLexer;

$lexer = new StreamLexer(fopen('my-games.pgn', 'r'));

$token = $lexer->getNextToken();

Contributing

Please see CONTRIBUTING and CONDUCT for details., (*8)

Security

If you discover any security related issues, please report them via HackerOne., (*9)

License

The MIT License (MIT). Please see License File for more information., (*10)

The Versions

29/11 2017

dev-master

9999999-dev

A PHP library to parse and write chess games in the portable game notation (PGN) format.

  Sources   Download

MIT

The Requires

 

The Development Requires

29/11 2017

1.0.2

1.0.2.0

A PHP library to parse and write chess games in the portable game notation (PGN) format.

  Sources   Download

MIT

The Requires

 

The Development Requires

13/10 2017

1.0.1

1.0.1.0

A PHP library to parse and write chess games in the portable game notation (PGN) format.

  Sources   Download

MIT

The Requires

 

The Development Requires

13/10 2017

1.0.0

1.0.0.0

A PHP library to parse and write chess games in the portable game notation (PGN) format.

  Sources   Download

MIT

The Requires

 

The Development Requires