Download the PHP package dragon-code/card-number without Composer

On this page you can find all versions of the php package dragon-code/card-number. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package card-number

Card Number using Luhn's algorithm

Luhn-algorithm card-number

Stable Version Unstable Version Total Downloads

Introduction

Generation and verification of card numbers using Luhn's algorithm: credit, customer loyalty and others.

Installation

To get the latest version of Card Number, simply require the project using Composer:

Or manually update require block of composer.json and run composer update console command.

Usage

Validation

You can validate any numbers with the Luhn algorithm with any input format.

For example:

You can validate bank card numbers. To do this, pass the card type as the second argument:

You can also check for invalid numbers:

In addition to numerical values, you can also validate number-letter combinations. For example:

List of available validation types:

Type Code Enum
AmericanExpress amex DragonCode\CardNumber\Enums\CardType::americanExpress
Chars Number chars DragonCode\CardNumber\Enums\CardType::chars
Dankort dankort DragonCode\CardNumber\Enums\CardType::dankort
DinersClub dinersclub DragonCode\CardNumber\Enums\CardType::dinersClub
Discovery discovery DragonCode\CardNumber\Enums\CardType::discovery
Forbrugsforeningen forbrugsforeningen DragonCode\CardNumber\Enums\CardType::forbrugsforeningen
HiperCard hipercard DragonCode\CardNumber\Enums\CardType::hiperCard
Jcb jcb DragonCode\CardNumber\Enums\CardType::jcb
Maestro maestro DragonCode\CardNumber\Enums\CardType::maestro
MasterCard mastercard DragonCode\CardNumber\Enums\CardType::masterCard
Mir mir DragonCode\CardNumber\Enums\CardType::mir
Ralf Ringer ralfringer DragonCode\CardNumber\Enums\CardType::ralfRinger
Troy troy DragonCode\CardNumber\Enums\CardType::troy
Unionpay unionpay DragonCode\CardNumber\Enums\CardType::unionPay
Visa visa DragonCode\CardNumber\Enums\CardType::visa
VisaElectron visaelectron DragonCode\CardNumber\Enums\CardType::visaElectron
Yves Rocher yvesrocher DragonCode\CardNumber\Enums\CardType::yvesRocher

Custom Validators

In some cases there may not be enough built-in validators and therefore you can easily use your own. To do this, create a class and inherit it from the abstract DragonCode\CardNumber\Validators\CardValidator, and then pass a reference to it in the cardType parameter:

Generation

You can also easily generate any numbers using the Luhn algorithm:

You can also use the formatter to format the resulting value:

Formatters

You can also create your own formatter. To do this, create a class and inherit it from the DragonCode\CardNumber\Formatters\Formatter abstract class:

And use this one:

List of available formatters:

  • DragonCode\CardNumber\Formatters\DefaultFormatter
  • DragonCode\CardNumber\Formatters\BankFormatter
  • DragonCode\CardNumber\Formatters\LoyaltyFormatter
  • DragonCode\CardNumber\Formatters\LoyaltyCharFormatter

In addition to numeric formatters, you can also use number-letter combinations. For example, using the DragonCode\CardNumber\Formatters\LoyaltyCharFormatter formatter, you can generate a letter code instead of a numeric number, which will be valid when verified by the Luhn's algorithm:

Factories

In addition, you can specify factories as an incoming identifier parameter. In this way, you can form unique identification rules using fluent methods.

This is useful when, for example, you create a customer loyalty card number and want to specify in its number the year of issue as well as its level.

List of available factories:

  • DragonCode\CardNumber\Factories\BankFactory
  • DragonCode\CardNumber\Factories\CustomerFactory

Laravel

If you use the Laravel framework, you can also use the validation rule:

You can also check bank cards:

License

This package is licensed under the MIT License.


All versions of card-number with dependencies

PHP Build Version
Package Version
Requires php Version ^8.1
archtechx/enums Version ^0.3.2
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package dragon-code/card-number contains the following files

Loading the files please wait ....