PHPackages                             annaghd/php-credit-card-validator-plus - 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. annaghd/php-credit-card-validator-plus

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

annaghd/php-credit-card-validator-plus
======================================

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

1.0.2(10y ago)112.9k↓11.1%MITPHPPHP &gt;=5.3.0

Since Nov 27Pushed 8y agoCompare

[ Source](https://github.com/annaghd/php-credit-card-validator)[ Packagist](https://packagist.org/packages/annaghd/php-credit-card-validator-plus)[ RSS](/packages/annaghd-php-credit-card-validator-plus/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (2)Versions (4)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)

Require the package in `composer.json`

```
"require": {
    "annaghd/php-credit-card-validator-plus": "1.*"
},
```

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)

```
$validMonth = CreditCard::validMonth('07'); // past date
var_dump($validMonth);

$validYear = CreditCard::validYear('2007'); // past date
var_dump($validYear);
```

Output:

```
bool(false)

bool(false)

```

Tests
-----

[](#tests)

Execute the following command to run the unit tests:

```
vendor/bin/phpunit

```

###  Health Score

32

—

LowBetter than 72% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity26

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity60

Established project with proven stability

 Bus Factor1

Top contributor holds 80% 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 ~109 days

Total

3

Last Release

3970d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/28302903?v=4)[annaghd](/maintainers/annaghd)[@annaghd](https://github.com/annaghd)

---

Top Contributors

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

---

Tags

laravelvalidatorcreditcardcardcreditdebitcvccardscreditcards

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  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)
