Download the PHP package alancole/vouchers without Composer

On this page you can find all versions of the php package alancole/vouchers. 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 vouchers

StyleCI Build Status

Vouchers Lib

A PHP library for generating and validating vouchers. We make no assumptions about storage and instead offer the concept of Bags which can take any number of Vouchers. These bags can validate vouchers, generate new vouchers and apply validation rules across the whole set.

Install

Example

Vouchers

Vouchers can take on almost any form, however you can use Vouchers\Voucher\Model to enforce validation and structure. The only required attribute is code which by default is immutable.

You may also pass an array to the voucher to set pre existing values to the voucher. Matching fields (including code) will be validated.

Any value passed on voucher creation can be get and set using get() and set() on the voucher.

Model

By creating a model you can set default values and validation on vouchers created or loaded. Models are passed as an array to Vouchers\Voucher\Model

If you set a voucher attribute as immutable then Voucher will throw the ImmutableData exception.

Code

You can change the way the code is generated by settings generator on a model. A generator must implement Vouchers\Voucher\Code\GeneratorInterface

Then tell the model to use this generator.

Bags

Bags act as collections for vouchers and allow you to enforce validations on a whole set. Bags can also act as a selector for vouchers, allowing to you pick a voucher at random and enforce rules on that selection. Bags are also Iterable so they can be used in loops.

You can use Vouchers\Voucher\Model to enfore a model on all items in a bag by passing a model as the first attribute on construction.

You can fill a model with existing vouchers by using add() add will only accept an instance of Vouchers\Voucher

You can also run a map on any array, mapping the return as new vouchers within the bag. This is handy if you need to transform data to fit a model.

You can get a voucher by code, which can be used to see if a voucher exists.

Pick

You can have the bag pick you a voucher at random by using pick() on any bag.

If you wish to validate the selection you can pass a callback to pick which will run until it returns a true or throw an Vouchers\Exceptions\NoValidVouchers exception.

You may also ask pick() to check all validators this bag might have (see Validate) and only return a voucher that is valid. Again this will throw Vouchers\Exceptions\NoValidVouchers is it doesn't find a voucher.

Validate

You can add validators to a bag, these validators can be used to validate requirements of a voucher using validate() on a bag and passing the voucher code as a parameter.

Validators can be added as callbacks to the validator function, or as a class that implements Vouchers\Voucher\Validator here is an example that assumes a voucher has an expire_date and checks it has not passed.

Kitchen Sink

This shows how to get vouchers from the subscriptions api, take a requested voucher, validate it and the claim it on the API.


All versions of vouchers with dependencies

PHP Build Version
Package Version
No informations.
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 alancole/vouchers contains the following files

Loading the files please wait ....