PHPackages                             marvinlabs/laravel-luhn - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. marvinlabs/laravel-luhn

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

marvinlabs/laravel-luhn
=======================

Luhn algorithm for Laravel

v1.0.13(1y ago)108409.7k↓14.5%11[2 PRs](https://github.com/marvinlabs/laravel-luhn/pulls)MITPHPPHP &gt;=7.1CI failing

Since May 8Pushed 1y ago3 watchersCompare

[ Source](https://github.com/marvinlabs/laravel-luhn)[ Packagist](https://packagist.org/packages/marvinlabs/laravel-luhn)[ GitHub Sponsors](https://github.com/vpratfr)[ RSS](/packages/marvinlabs-laravel-luhn/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (4)Versions (14)Used By (0)

Laravel Luhn
============

[](#laravel-luhn)

[![Latest Version on Packagist](https://camo.githubusercontent.com/bc686715ae70e5c5ff0cbe5467b9e70126f40fbb48dc275485d609a093e0f3e1/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6d617276696e6c6162732f6c61726176656c2d6c75686e2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/marvinlabs/laravel-luhn)[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE.md)[![Total Downloads](https://camo.githubusercontent.com/e049c14a2d0bee815b25cbfdf2c212250b52febd3fc6bc970ded123ade0a34d0/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6d617276696e6c6162732f6c61726176656c2d6c75686e2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/marvinlabs/laravel-luhn)[![Build Status](https://github.com/marvinlabs/laravel-luhn/workflows/build/badge.svg)](https://github.com/marvinlabs/laravel-luhn/actions)

`marvinlabs/laravel-luhn` is a laravel package providing various Laravel utilities to work with the Luhn algorithm such as:

- a few validation rules
- dependency injection
- facade

The Luhn algorithm is used widely to verify that numbers are valid: credit card numbers, SIREN company codes, etc.

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

[](#installation)

You can install the package via composer:

```
composer require marvinlabs/laravel-luhn
```

If you are using Laravel 5.5, the service provider and facade will automatically be discovered.

On earlier versions, you need to do that manually. You must install the service provider:

```
// config/app.php
'providers' => [
    ...
    MarvinLabs\Luhn\LuhnServiceProvider::class
];
```

And optionally register an alias for the facade.

```
// config/app.php
'aliases' => [
    ...
    'Luhn' => MarvinLabs\Luhn\Facades\Luhn::class,
];
```

Usage
-----

[](#usage)

### Algorithm implementation

[](#algorithm-implementation)

The package provides an implementation to the algorithm interface defined in `\MarvinLabs\Luhn\Contracts\LuhnAlgorithm`.

The contract provides 3 public methods to:

- Check if an input string is valid according to the Luhn algorithm
- Compute the check digit to append to a string in order to make it valid
- Compute the checksum according to the Luhn algorithm

### Facade

[](#facade)

A facade is provided to access the Luhn algorithm implementation.

```
Luhn::isValid('1234');
Luhn::computeCheckDigit('1234');
Luhn::computeCheckSum('1234');
```

### Dependency injection

[](#dependency-injection)

You can get an implementation of the Luhn algorithm at any time using the Laravel container.

```
$luhn = app(\MarvinLabs\Luhn\Contracts\LuhnAlgorithm::class); // Using the interface
$luhn = app('luhn'); // This shortcut works too, up to you ;)
```

### Validation

[](#validation)

The package provides custom rules to validate a string.

```
$validator = Validator::make($data, [
    'number1' => 'luhn',         // Using shorthand notation
    'number2' => new LuhnRule(), // Using custom rule class
]);
```

Version history
---------------

[](#version-history)

See the [dedicated change log](CHANGELOG.md)

Credits
-------

[](#credits)

- Got some ideas from [nekman/luhn-algorithm](https://github.com/nekman/luhn-algorithm)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

49

—

FairBetter than 95% of packages

Maintenance46

Moderate activity, may be stable

Popularity52

Moderate usage in the ecosystem

Community18

Small or concentrated contributor base

Maturity65

Established project with proven stability

 Bus Factor1

Top contributor holds 70.3% 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

Every ~210 days

Recently: every ~406 days

Total

13

Last Release

405d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/2526465?v=4)[Vincent Prat](/maintainers/vpratfr)[@vpratfr](https://github.com/vpratfr)

---

Top Contributors

[![vpratfr](https://avatars.githubusercontent.com/u/2526465?v=4)](https://github.com/vpratfr "vpratfr (26 commits)")[![laravel-shift](https://avatars.githubusercontent.com/u/15991828?v=4)](https://github.com/laravel-shift "laravel-shift (4 commits)")[![klimov-paul](https://avatars.githubusercontent.com/u/1482054?v=4)](https://github.com/klimov-paul "klimov-paul (3 commits)")[![kduma](https://avatars.githubusercontent.com/u/1062582?v=4)](https://github.com/kduma "kduma (2 commits)")[![Swop](https://avatars.githubusercontent.com/u/545340?v=4)](https://github.com/Swop "Swop (1 commits)")[![vanodevium](https://avatars.githubusercontent.com/u/16780069?v=4)](https://github.com/vanodevium "vanodevium (1 commits)")

---

Tags

laravelSirencredit-cardluhnSiret

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/marvinlabs-laravel-luhn/health.svg)

```
[![Health](https://phpackages.com/badges/marvinlabs-laravel-luhn/health.svg)](https://phpackages.com/packages/marvinlabs-laravel-luhn)
```

###  Alternatives

[barryvdh/laravel-ide-helper

Laravel IDE Helper, generates correct PHPDocs for all Facade classes, to improve auto-completion.

14.9k123.0M687](/packages/barryvdh-laravel-ide-helper)[interaction-design-foundation/laravel-geoip

Support for multiple Geographical Location services.

17221.0k3](/packages/interaction-design-foundation-laravel-geoip)[nedwors/navigator

A Laravel package to ease defining navigation menus

433.1k](/packages/nedwors-navigator)[xefi/faker-php-laravel

Faker php integration with laravel

1915.1k](/packages/xefi-faker-php-laravel)[dcblogdev/laravel-junie

Install pre-configured guides for Jetbrains Junie

392.5k](/packages/dcblogdev-laravel-junie)

PHPackages © 2026

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