PHPackages                             lytrax/afm - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Validation &amp; Sanitization](/categories/validation)
4. /
5. lytrax/afm

ActiveLibrary[Validation &amp; Sanitization](/categories/validation)

lytrax/afm
==========

Greek AFM (TIN) validator and generator

1.0.0(6y ago)31.2k↓50%1MITPHPPHP &gt;=7.2.0CI failing

Since Jan 2Pushed 6y ago1 watchersCompare

[ Source](https://github.com/clytras/afm-php)[ Packagist](https://packagist.org/packages/lytrax/afm)[ RSS](/packages/lytrax-afm/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (1)Dependencies (1)Versions (2)Used By (0)

Greek TIN/AFM Validator and Generator
=====================================

[](#greek-tinafm-validator-and-generator)

[![Linux Build Status](https://camo.githubusercontent.com/3837ac843d90fc0a143a5a6cfb6841c0489f0536a0e25e0829a71ddc910ba3b1/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f636c79747261732f61666d2d7068702e7376673f7374796c653d666c6174)](https://travis-ci.org/clytras/afm-php?branch=master) [![Packagist](https://camo.githubusercontent.com/2606d7e68407a725204ab8335b19bd95be86a1a24408e97828923c486d3b7fb2/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6c79747261782f61666d)](https://packagist.org/packages/lytrax/afm)

[![Logo](https://github.com/clytras/afm-php/raw/master/resources/LytraxAFM_logo.png)](https://github.com/clytras/afm-php/raw/master/resources/LytraxAFM_logo.png)

Validate and generate Greek TIN (*Tax Identification Number*) / AFM (*Αριθμός Φορολογικού Μητρώου*). Generation function can create valid or invalid numbers including parameters for old format, individuals, legal entities and repet tolerance digits control.

Online demo and presentation
----------------------------

[](#online-demo-and-presentation)

Installation
------------

[](#installation)

```
composer require lytrax/afm

```

Usage
-----

[](#usage)

Use one or more functions:

```
use function Lytrax\AFM\validateAFM;
use function Lytrax\AFM\generateAFM;
use function Lytrax\AFM\generateValidAFM;
use function Lytrax\AFM\generateInvalidAFM;
```

Validate a number:

```
validateAFM('090000045');
bool(true)

validateAFM('123456789');
bool(false)
```

Generate a valid number:

```
generateValidAFM();
string(9) "731385437"
```

Generate an invalid number:

```
generateInvalidAFM();
string(9) "853003357"
```

API
---

[](#api)

**validateAFM** `($afm, $params = [])`

- `$afm: string` - A number to be checked
- `$params: array (optional)` - Optional associative array for named parameters
- `$params['extendedResult']: boolean = false` - Return a `boolean` or `array`
- **Returns**: `boolean` or `array` (Associative array with `valid: boolean` and `error: string ('length' or 'nan' or 'zero' or 'invalid')`)

Example:

```
validateAFM('ab1234', ['extendedResult' => true]);
array(2) {
  ["valid"]=>
  bool(false)
  ["error"]=>
  string(6) "length"
}
```

**generateAFM** `($params = [])`

- `$params: array (optional)` - Optional associative array for named parameters
- `$params['forceFirstDigit']: null|int (optional)` - If specified, overrides all pre99, legalEntity and individual
- `$params['pre99']: boolean = false` - Για ΑΦΜ πριν από 1/1/1999 (ξεκινάει με 0), (if true, overrides both legalEntity and individual)
- `$params['individual']: boolean = false` - Φυσικά πρόσωπα, (ξεκινάει με 1-4)
- `$params['legalEntity']: boolean = false` - Νομικές οντότητες (ξεκινάει με 7-9)
- `$params['repeatTolerance']: null|int (optional)` - Number for max repeat tolerance (0 for no repeats, unspecified for no check)
- `$params['valid']: boolean = true` - Generate valid or invalid AFM
- **Returns**: `string` - A valid or invalid 9 digit AFM number

Example:

```
generateAFM([
  'forceFirstDigit' => 3,
  'repeatTolerance' => 1,
  'valid' => true
]);
string(9) "335151580"
```

**generateValidAFM** - Same as `generateAFM` with `$params['valid']` force and override to `true`

- **Returns**: `string` - A valid 9 digit AFM number

Example:

```
generateValidAFM(['pre99' => true]);
string(9) "070825250"
```

**generateInvalidAFM** - Same as `generateAFM` with `$params['valid']` force and override to `false`

- **Returns**: `string` - An invalid 9 digit AFM number

Example:

```
generateInvalidAFM(['legalEntity' => true]);
string(9) "877577341"
```

Test
----

[](#test)

Clone this repository, intall packages and run PHPUnit:

```
git clone https://github.com/clytras/afm-php.git && cd afm-php
composer install
./vendor/bin/phpunit --testdox

```

Run Demo:

```
php ./demo/index.php

```

Changelog
---------

[](#changelog)

See [CHANGELOG](https://github.com/clytras/afm-php/blob/master/CHANGELOG.md)

License
-------

[](#license)

MIT License - see the [LICENSE](https://github.com/clytras/afm-php/blob/master/LICENSE) file for details

###  Health Score

28

—

LowBetter than 54% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity22

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity52

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

2328d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/3c63300fd4cfcb45ec0d611acb7ca15da0fbc7c671bf1e907fee8f36dba7ef63?d=identicon)[clytras](/maintainers/clytras)

---

Top Contributors

[![clytras](https://avatars.githubusercontent.com/u/6103077?v=4)](https://github.com/clytras "clytras (13 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/lytrax-afm/health.svg)

```
[![Health](https://phpackages.com/badges/lytrax-afm/health.svg)](https://phpackages.com/packages/lytrax-afm)
```

###  Alternatives

[webmozart/assert

Assertions to validate method input/output with nice error messages.

7.6k894.0M1.2k](/packages/webmozart-assert)[bensampo/laravel-enum

Simple, extensible and powerful enumeration implementation for Laravel.

2.0k15.9M104](/packages/bensampo-laravel-enum)[swaggest/json-schema

High definition PHP structures with JSON-schema based validation

48612.5M73](/packages/swaggest-json-schema)[stevebauman/purify

An HTML Purifier / Sanitizer for Laravel

5325.6M19](/packages/stevebauman-purify)[ashallendesign/laravel-config-validator

A package for validating your Laravel app's config.

217905.3k5](/packages/ashallendesign-laravel-config-validator)[crazybooot/base64-validation

Laravel validators for base64 encoded files

1341.9M8](/packages/crazybooot-base64-validation)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
