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.14(2mo ago)108443.0k↓64.3%11MITPHPPHP &gt;=7.1CI failing

Since May 8Pushed 2mo ago3 watchersCompare

[ Source](https://github.com/vpratfr/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 2d ago

READMEChangelog (10)Dependencies (8)Versions (15)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

59

—

FairBetter than 98% of packages

Maintenance85

Actively maintained with recent releases

Popularity51

Moderate usage in the ecosystem

Community18

Small or concentrated contributor base

Maturity66

Established project with proven stability

 Bus Factor1

Top contributor holds 68.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 ~223 days

Recently: every ~380 days

Total

14

Last Release

77d 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 (28 commits)")[![laravel-shift](https://avatars.githubusercontent.com/u/15991828?v=4)](https://github.com/laravel-shift "laravel-shift (6 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

[psalm/plugin-laravel

Psalm plugin for Laravel

3355.3M346](/packages/psalm-plugin-laravel)[renatomarinho/laravel-page-speed

Laravel Page Speed

2.5k1.7M11](/packages/renatomarinho-laravel-page-speed)[vinkius-labs/laravel-page-speed

Laravel Page Speed

2.5k12.5k1](/packages/vinkius-labs-laravel-page-speed)[emargareten/inertia-modal

Inertia Modal is a Laravel package that lets you implement backend-driven modal dialogs for Inertia apps.

90142.9k](/packages/emargareten-inertia-modal)[wearepixel/laravel-cart

A cart implementation for Laravel

1374.8k](/packages/wearepixel-laravel-cart)[tomshaw/electricgrid

A feature-rich Livewire package designed for projects that require dynamic, interactive data tables.

119.4k](/packages/tomshaw-electricgrid)

PHPackages © 2026

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