承接 marvinlabs/laravel-luhn 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

marvinlabs/laravel-luhn

最新稳定版本:v1.0.13

Composer 安装命令:

composer require marvinlabs/laravel-luhn

包简介

Luhn algorithm for Laravel

README 文档

README

Latest Version on Packagist Software License Total Downloads Build Status

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

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

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

A facade is provided to access the Luhn algorithm implementation.

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

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

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

See the dedicated change log

Credits

License

The MIT License (MIT). Please see License File for more information.

统计信息

  • 总下载量: 375.22k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 108
  • 点击次数: 3
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 108
  • Watchers: 3
  • Forks: 11
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-01-04

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固