Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Tckimlik Laravel Package

epigra/tckimlik

A PHP package for validating and generating Turkish TC Kimlik (national ID) numbers, with Laravel validation rule support and a simple API for checking ID format and checksum, making Turkish identity verification easy to add to forms and applications.

View on GitHub
Deep Wiki
Context7

Getting Started

Install via Composer (composer require epigra/tckimlik). The package is a single-purpose utility for Turkish Identification Numbers (TCKN). Start by reading the README and src/TcKimlik.php; there is no config file or migrations. The first use case is algorithmic validation:

use Epigra\TcKimlik;

TcKimlik::validate('10000000146'); // bool
TcKimlik::generate();              // returns a checksum-valid TCKN

No service provider registration is required unless you want the facade alias. In Laravel, you can call the class statically or inject it if you bind it in a service provider.

Implementation Patterns

  • Custom validation rule – wrap TcKimlik::validate() in a Rule object or closure for form requests:
    'tcno' => ['required', 'string', 'size:11', function ($attr, $value, $fail) {
        if (! TcKimlik::validate($value)) {
            $fail('Geçersiz TC Kimlik No.');
        }
    }],
    
  • Model casting / accessor – store TCKN as a string (never an integer) and validate before saving. You can add a setTcnoAttribute mutator that rejects invalid values.
  • Test data generation – use TcKimlik::generate() in factories and seeders when you need realistic-looking but checksum-valid numbers. Do not use generated numbers as real identities.
  • Form request integration – create a TcKimlikRule class in app/Rules and reuse it across registration, profile, and checkout forms.

Gotchas and Tips

  • This is checksum validation only. The package validates the TCKN algorithm (11 digits, first digit non-zero, two checksum digits). It does not confirm that the number belongs to a real person. For official identity verification you need the NVI service or a paid provider.
  • Generated numbers are not safe for production identity data. They are algorithmically valid but may collide with real citizens. Use them only for tests, demos, and seeders.
  • Always treat TCKN as a string. Leading zeros are valid in the algorithm, and PHP integers will strip them. Validate length and digits before calling validate().
  • v1.2.0 introduced Transliterator in trUpper. This method now relies on PHP’s intl extension to correctly uppercase Turkish characters (i → İ). Ensure ext-intl is installed in all environments (local, CI, production). If trUpper throws or behaves unexpectedly after upgrading, check php -m | grep intl.
  • No Laravel auto-discovery dependencies. If you use the facade, register Epigra\TcKimlik in config/app.php aliases or use the fully qualified class name.
  • Debugging tip: When a TCKN fails validation, log the raw value and length before passing it to the package. Common failures are whitespace, non-digit characters, or integer casting.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
se7enxweb/flysystem
lampwick/laravel
jeslage/statamic-emojis
micahdshackelford/rmap-laravel
draftsmaninc/draftsman
square-bit/laravel-volition
himito/laravel-mailman
htinlynn/genius-helper
maco-studios/hephaestus
elmogy/larafast
xeviant/laravel-paystack
gorilladash/laravel-website-sdk
martialbe/flysystem-oss
chondal/3312client
jeroen-g/flickr
opscale-co/nova-genbi
itsjustvita/laravel-retention
tequilarapido/trackit
gregsphotography/site-builder-filament
cabaoctavio/laravel-query-log