A small library for validating and generating International Bankaccount Numbers (IBAN). It is build for PHP 5.3+.
This library is ready to use. The iban validation should be run fine, but there is no warranty for the generation functionality. Please use it at your own risk.
To install jschaedl/iban install Composer first, if you haven't already
curl -sS https://getcomposer.org/installer | php
Then just add the following to your composer.json file:
// composer.json
{
"require": {
"jschaedl/iban": "1.1.6"
}
}
Then, you can install the new dependencies by running Composer’s update command from the directory where your composer.json
file is located:
# install
$ php composer.phar install
# update
$ php composer.phar update jschaedl/iban
# or you can simply execute composer command if you set it to
# your PATH environment variable
$ composer install
$ composer update jschaedl/iban
You can see this library on Packagist.
Composer installs autoloader at ./vendor/autoload.php
. If you use jschaedl/iban in your php script, add:
require_once 'vendor/autoload.php';
Or you can use git clone command:
# HTTP
$ git clone https://github.com/jschaedl/Iban.git
# SSH
$ git clone [email protected]:jschaedl/Iban.git
<?php
use IBAN\Validation\IBANValidator;
use IBAN\Generation\IBANGenerator;
use IBAN\Rule\RuleFactory;
// validation example
$ibanValidator = new IBANValidator();
if ($ibanValidator->validate('DE89370400440532013000')) {
echo "DE89370400440532013000 is valid!";
}
// generate german iban example #1
$ibanGenerator = new IBANGeneratorDE();
$generatedIban = $ibanGenerator->generate('60050101', '502502502');
// $generatedIban => DE15600501010001108884
// generate german iban example #2
$generatedIban = IBANGenerator::DE('60050101', '502502502');
// $generatedIban => DE15600501010001108884
// generate dutch iban example #1
$ibanGenerator = new IBANGeneratorNL();
$generatedIban = $ibanGenerator->generate('ABNA', '123456789');
// $generatedIban => NL02ABNA0123456789
// generate dutch iban example #2
$generatedIban = IBANGenerator::NL('ABNA', '123456789');
// $generatedIban => NL02ABNA0123456789
If you want to fix some bugs or want to enhance some functionality, please fork the master branch and create your own development branch. Then fix the bug you found or add your enhancements and make a pull request. Please commit your changes in tiny steps and add a detailed description on every commit.
All pull requests must be accompanied by passing unit tests. This repository uses phpunit and Composer. You must run composer install
to install this package's dependencies before the unit tests will run. You can run the test via:
phpunit -c tests/phpunit.xml tests/
- add support for more countries
MIT Public License