Skip to content
A library to calculate the italian fiscal code (codice fiscale)
Branch: master
Clone or download
Latest commit 92a9a9a Nov 29, 2014


A library to calculate and check the validity of the italian fiscal code (codice fiscale).

Build Status Latest Stable Version Total Downloads License


  • php >= 5.4


Create a composer.json file with the following content:

    "require": {
        "usu/codice-fiscale": "1.0.*"

Then run

$ curl -s | php
$ php composer.phar install

You should now have CodiceFiscale installed inside your vendor folder: vendor/usu/codice-fiscale

And an handy autoload file to include in you project: vendor/autoload.php

How to use

require_once __DIR__ . '/vendor/autoload.php';

use CodiceFiscale\Calculator;
use CodiceFiscale\Checker;

$calc = new Calculator();
$calc->calcola('Nome', 'Cognome', 'M', new \DateTime('1992-03-06'), 'F205');

$chk = new Checker();
if ($chk->isFormallyCorrect('RSSMRA79S18F205J')) {
    print('Codice Fiscale formally correct');
    printf('Birth Day: %s',     $chk->getDayBirth());
    printf('Birth Month: %s',   $chk->getMonthBirth());
    printf('Birth Year: %s',    $chk->getYearBirth());
    printf('Birth Country: %s', $chk->getCountryBirth());
    printf('Sex: %s',           $chk->getSex());
} else {
    print('Codice Fiscale wrong');


The library is fully tested with PHPUnit.

Go to the root folder, install the dev dependencies with composer, and then run the phpunit test suite

$ composer --dev install
$ ./vendor/bin/phpunit
You can’t perform that action at this time.