PHPackages                             imaddev/php-credit-card-validator - 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. [Validation &amp; Sanitization](/categories/validation)
4. /
5. imaddev/php-credit-card-validator

ActiveLibrary[Validation &amp; Sanitization](/categories/validation)

imaddev/php-credit-card-validator
=================================

Validates popular debit and credit cards numbers against regular expressions and Luhn algorithm. Also validates the CVC and the expiration date

1.0.4(4y ago)029MITPHPPHP &gt;=5.3.0

Since Nov 27Pushed 4y agoCompare

[ Source](https://github.com/imaddev/php-credit-card-validator)[ Packagist](https://packagist.org/packages/imaddev/php-credit-card-validator)[ RSS](/packages/imaddev-php-credit-card-validator/feed)WikiDiscussions master Synced 4w ago

READMEChangelog (2)Dependencies (2)Versions (6)Used By (0)

PHP Credit Card Validator
=========================

[](#php-credit-card-validator)

[![Build Status](https://camo.githubusercontent.com/940606cbb6172cf2b8491d3134377a003af38b7f71ed68098156e834b39380fc/68747470733a2f2f7472617669732d63692e6f72672f696e6163686f2f7068702d6372656469742d636172642d76616c696461746f722e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/inacho/php-credit-card-validator) [![Coverage Status](https://camo.githubusercontent.com/07fcb4aaf7a1cfabe5e1bd464fd13dbc4aba12c1fa1d271ae75c318839b0a3bb/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f696e6163686f2f7068702d6372656469742d636172642d76616c696461746f722f62616467652e7376673f6272616e63683d6d617374657226736572766963653d676974687562)](https://coveralls.io/github/inacho/php-credit-card-validator?branch=master) [![Latest Stable Version](https://camo.githubusercontent.com/c19c0c0803e6d724cd75bc0242c42ec138e12a3e3264aa4ca47c46fd4d98913a/68747470733a2f2f706f7365722e707567782e6f72672f696e6163686f2f7068702d6372656469742d636172642d76616c696461746f722f76657273696f6e)](https://packagist.org/packages/inacho/php-credit-card-validator) [![Total Downloads](https://camo.githubusercontent.com/774269408cc89b547120d5d54cd85cf2e4b6a6da17aea658ec825ab16733425d/68747470733a2f2f706f7365722e707567782e6f72672f696e6163686f2f7068702d6372656469742d636172642d76616c696461746f722f646f776e6c6f616473)](https://packagist.org/packages/inacho/php-credit-card-validator)

Validates popular debit and credit cards numbers against regular expressions and Luhn algorithm. Also validates the CVC and the expiration date.

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

[](#installation)

```
composer require imaddev/php-credit-card-validator
```

If you are using Laravel, add an alias in `config/app.php`

```
'aliases' => array(

    'App'             => 'Illuminate\Support\Facades\App',
    ...
    'View'            => 'Illuminate\Support\Facades\View',

    'CreditCard'      => 'Inacho\CreditCard',

),
```

Usage
-----

[](#usage)

### Validate a card number knowing the type:

[](#validate-a-card-number-knowing-the-type)

```
$card = CreditCard::validCreditCard('5500005555555559', 'mastercard');
print_r($card);
```

Output:

```
Array
(
    [valid] => 1
    [number] => 5500005555555559
    [type] => mastercard
)

```

### Validate a card number and return the type:

[](#validate-a-card-number-and-return-the-type)

```
$card = CreditCard::validCreditCard('371449635398431');
print_r($card);
```

Output:

```
Array
(
    [valid] => 1
    [number] => 371449635398431
    [type] => amex
)

```

### Validate the CVC

[](#validate-the-cvc)

```
$validCvc = CreditCard::validCvc('234', 'visa');
var_dump($validCvc);
```

Output:

```
bool(true)

```

### Validate the expiration date

[](#validate-the-expiration-date)

```
$validDate = CreditCard::validDate('2013', '07'); // past date
var_dump($validDate);
```

Output:

```
bool(false)

```

Tests
-----

[](#tests)

Execute the following command to run the unit tests:

```
vendor/bin/phpunit

```

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity62

Established project with proven stability

 Bus Factor1

Top contributor holds 69.6% 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 ~666 days

Total

5

Last Release

1517d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/6618ec3a5d91bfc351987e73aea0cd4472c9ec35ce18d9cc201ac4b837f4965d?d=identicon)[imaddev](/maintainers/imaddev)

---

Top Contributors

[![inacho](https://avatars.githubusercontent.com/u/742624?v=4)](https://github.com/inacho "inacho (16 commits)")[![imaddev](https://avatars.githubusercontent.com/u/13138520?v=4)](https://github.com/imaddev "imaddev (7 commits)")

---

Tags

laravelvalidatorcreditcardcardcreditdebitcvccardscreditcards

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/imaddev-php-credit-card-validator/health.svg)

```
[![Health](https://phpackages.com/badges/imaddev-php-credit-card-validator/health.svg)](https://phpackages.com/packages/imaddev-php-credit-card-validator)
```

###  Alternatives

[inacho/php-credit-card-validator

Validates popular debit and credit cards numbers against regular expressions and Luhn algorithm. Also validates the CVC and the expiration date

2051.4M11](/packages/inacho-php-credit-card-validator)[intervention/validation

Additional validation rules for the Laravel framework

6826.7M8](/packages/intervention-validation)[jlorente/php-credit-cards

A PHP package to perform operations on debit and credit cards like format, validate brand, number and Luhn algorithm. It validates popular brands like Visa, Mastercard, American Express, etc.

44421.2k1](/packages/jlorente-php-credit-cards)[freelancehunt/php-credit-card-validator

Validates popular debit and credit cards' numbers against regular expressions and Luhn algorithm. Also validates the CVC and the expiration date.

18620.4k2](/packages/freelancehunt-php-credit-card-validator)[dragon-code/card-number

Generation and verification of card numbers using Luhn's algorithm.

6512.8k](/packages/dragon-code-card-number)[stuyam/laravel-phone-validator

A phone validator for Laravel using the free Twilio phone lookup service.

2861.3k](/packages/stuyam-laravel-phone-validator)

PHPackages © 2026

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