pontedilana/codice-fiscale

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

Maintainers

👁 endelwar

Package info

github.com/pontedilana/codice-fiscale

pkg:composer/pontedilana/codice-fiscale

Statistics

Installs: 146

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

2.0.0 2025-08-22 12:55 UTC

Requires

Suggests

None

Provides

None

Conflicts

None

Replaces

None

MIT de81a5dfb443104053fc3816b6a1f7b14444053b

phpcodice fiscale

This package is auto-updated.

Last update: 2026-06-22 14:51:43 UTC


README

A library to calculate and check the validity of the Italian fiscal code (codice fiscale). Based on the original work of andreausu, with the contribution of fdisotto.

👁 Latest Stable Version
👁 Total Downloads
👁 License

Requirements

  • php >= 8.1

Installation

Add the library with the following command

composer require pontedilana/codice-fiscale

How to use

<?php
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');
}

Testing

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