Download the PHP package x-adam/tr-tax-number-validation without Composer

On this page you can find all versions of the php package x-adam/tr-tax-number-validation. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package tr-tax-number-validation

Turkish Tax Number Validation

Tests Latest Stable Version PHP Version Total Downloads License

Offline validation for Turkish tax identification numbers (Vergi Kimlik No). Zero dependencies, a single static method, and no network access — the number is checked against the official checksum rule.

Requirements

PHP 8.1 or higher. Nothing else.

Installation

Usage

Both int and string are accepted, so values coming straight from a request need no casting or pre-filtering. Anything that is not a well-formed tax number — letters, empty strings, surrounding whitespace, wrong length — returns false instead of throwing:

What it checks

A Turkish tax number is 10 digits long; the last one is a check digit computed from the first nine. For each of the first nine digits d at position p (counted from 9 down to 1):

Step Formula
Intermediate m = (d + p) mod 10
Weighted w = (m × 2^p) mod 9, except w = 9 when m = 9
Check digit (10 − Σw mod 10) mod 10

The library returns true only when the computed check digit equals the tenth digit.

What it does not check

This library answers "is this a well-formed tax number?", not "is this number registered to this taxpayer?". The latter requires querying the Revenue Administration (GİB), which is outside the scope of an offline checksum.

Use this library to reject malformed input early — before storing it, or before paying for a lookup.

Laravel

For a ready-made tr_tax_number validation rule, see x-laravel/validation-tr-tax-number-extend, which wraps this library.

Testing

The suite covers the documented rule, malformed input, generated valid numbers, and every combination of positions whose intermediate value is nine. CI runs it on PHP 8.1 through 8.5, along with PHPStan at its highest level.

License

Open source software licensed under the MIT license.


All versions of tr-tax-number-validation with dependencies

PHP Build Version
Package Version
Requires php Version >=8.1
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package x-adam/tr-tax-number-validation contains the following files

Loading the files please wait ...