PHP code example of marvinlabs / laravel-luhn

1. Go to this page and download the library: Download marvinlabs/laravel-luhn library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

marvinlabs / laravel-luhn example snippets


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

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

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

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

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