This package can be used to:
- validate an ISBN code
- convert codes between ISBN-10, ISBN-13 and EAN (without hyphens) formats
- calculate the checksum digit
- show the registration agency (country or language)
Install with composer:
composer require biblys/isbn:^2.1.5
Use case: converting an EAN (9782843449499) to an ISBN-13 (978-2-84344-949-9).
<?php
use Biblys\Isbn\Isbn as Isbn;
// require_once __DIR__.'/vendor/autoload.php';
$ean = '9782843449499';
$isbn = new Isbn($ean);
try {
$isbn->validate();
$isbn13 = $isbn->format("ISBN-13");
echo "ISBN-13: $isbn13";
} catch(Exception $e) {
echo "An error occured while parsing $ean: ".$e->getMessage();
}
Run tests with PHPUnit:
composer install
composer test
Run tests in a docker container:
composer docker:test
Run tests in a docker container using a specific PHP version:
PHP_VERSION=7.1 composer docker:test
New ISBN ranges may be added from time to time by the International ISBN Agency. Whenever it happens, this library must be updated. If a range update is necessary, please open an issue on Github. You can also open a pull request after updating the ranges your self with the following commands:
composer install
composer run update-ranges
Or using a docker container:
composer docker:update-ranges