PHPackages                             rplansky/credit-card - 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. rplansky/credit-card

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

rplansky/credit-card
====================

Simple package to generate and validate credit card numbers in PHP

34104.9k↑14.2%18PHP

Since Apr 12Pushed 3y ago6 watchersCompare

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

READMEChangelogDependenciesVersions (2)Used By (0)

Credit Card helpers in PHP
==========================

[](#credit-card-helpers-in-php)

This is a simple package to create and validate credit card numbers.

Installation via Composer
-------------------------

[](#installation-via-composer)

### In your project

[](#in-your-project)

To use this package in your project, add it to your `composer.json`

```
"require": {
    "rplansky/credit-card": "dev-master"
}
```

### Global Installation

[](#global-installation)

This kind of installation is useful to use `ccgenerator` and `ccvalidator`commands globally on command line

```
$ composer global require "rplansky/credit-card=*@dev"
```

Usage
-----

[](#usage)

### In code

[](#in-code)

#### Validate Numbers

[](#validate-numbers)

This validator uses the [Luhn Algorithm](http://en.wikipedia.org/wiki/Luhn_algorithm)

```
$validator = new Plansky\CreditCard\Validator();
$validator->isValid('57234651187928922');
// true
```

#### Generate Random Numbers

[](#generate-random-numbers)

##### Totally random

[](#totally-random)

```
$generator = new Plansky\CreditCard\Generator();
$generator->single();
// 99119662018492824
```

##### Prefix

[](#prefix)

You can generate a random number using a brand prefix.

```
$generator = new Plansky\CreditCard\Generator();
$generator->single(301); // Generates a DINERS number
// 30192056094873699
```

##### Length

[](#length)

Some brands have different number length.

```
$generator = new Plansky\CreditCard\Generator();
$generator->single(347, 15); // Generates an AMEX number
// 3479966030620031
```

#### Generating Lots

[](#generating-lots)

Using same parameters of `generate` method, except for the first parameter that is the amount of numbers that you want to generate, you can generate a lot of numbers at once

```
$generator = new Plansky\CreditCard\Generator();
$generator->lot(10, 347, 15); // Generates 10 AMEX numbers
// array(
//   0 => '3479132843454361',
//   1 => '3479587605801416',
//   2 => '3479861510504500',
//   3 => '3479130090772634',
//   4 => '3479427298826638',
//   5 => '3479894458677616',
//   6 => '3479713475691154',
//   7 => '3479468840371814',
//   8 => '3479219690811825',
//   9 => '3479326005723791'
// )
```

### In command line

[](#in-command-line)

#### ccgenerator

[](#ccgenerator)

You can use same parameters of `Generator::lot()` method, plus, `separator` parameter to render your output

```
$ ccgenerator --amount=3 --prefix=347 --length=15 --separator=" "
# 347544073859505 347615533406853 347845409364916
```

#### ccvalidator

[](#ccvalidator)

You can pass numbers separated by spaces to validate more than one number at once.

```
$ ccvalidator 347544073859505 347615533406852 347845409364916
# 347544073859505 | valid
# 347615533406852 | invalid
# 347845409364916 | valid
```

###  Health Score

33

—

LowBetter than 75% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity44

Moderate usage in the ecosystem

Community14

Small or concentrated contributor base

Maturity43

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% 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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/564194d2a45641b54ac5d6754e95394dfd0bc6fe649476e89e2e709bd5a89bbb?d=identicon)[rplansky](/maintainers/rplansky)

---

Top Contributors

[![rplansky](https://avatars.githubusercontent.com/u/572653?v=4)](https://github.com/rplansky "rplansky (36 commits)")

### Embed Badge

![Health badge](/badges/rplansky-credit-card/health.svg)

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

###  Alternatives

[webmozart/assert

Assertions to validate method input/output with nice error messages.

7.6k894.0M1.2k](/packages/webmozart-assert)[bensampo/laravel-enum

Simple, extensible and powerful enumeration implementation for Laravel.

2.0k15.9M104](/packages/bensampo-laravel-enum)[swaggest/json-schema

High definition PHP structures with JSON-schema based validation

48612.5M73](/packages/swaggest-json-schema)[stevebauman/purify

An HTML Purifier / Sanitizer for Laravel

5325.6M19](/packages/stevebauman-purify)[ashallendesign/laravel-config-validator

A package for validating your Laravel app's config.

217905.3k5](/packages/ashallendesign-laravel-config-validator)[crazybooot/base64-validation

Laravel validators for base64 encoded files

1341.9M8](/packages/crazybooot-base64-validation)

PHPackages © 2026

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