Download the PHP package teamgantt/dues without Composer
On this page you can find all versions of the php package teamgantt/dues. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package dues
dues
Table of Contents
- Goals
- Installation
- Usage
- Development
- Testing
- Conventions
Goals
Dues is meant to provide a high level API for processing payments, particularly subscriptions.
It is designed to be processor agnostic, but currently only supports Braintree.
Installation
Dues isn't currently published to packagist. Until it is, it is recommended that dues be
installed from the main
branch using composer's vcs functionality.
Your composer.json
should include the following:
See composer documentation for specifying a specific commit.
Usage
The high level API of dues is accessed by constructing a Dues
instance with a gateway implementation.
All functionality supported by dues can be found on the Dues
class.
Note: some of dues' public API is mixed in via a trait.
Events
Dues provides support for handling certain events via the the addListener
method. This method expects an implementation of the EventListener
interface.
A listener can be removed by calling removeEventListener
with the same instance.
Events are useful for logging, analytics, and other integrations (such as dealing with taxes).
Development
Dues is developed against PHP version 8.1
A Dockerfile is provided for a consistent development environment.
The provided commands in bin/
assume a docker image named dues
with a tag of dev
. You can build this from the root of the repo:
It is recommended, though not necessary, to use direnv for development. If direnv is installed, the .envrc
file will automatically be loaded when entering the project directory. This will allow developers to use the php
and composer
commands without having to install them locally. All composer
commands will be run transparently through the docker container.
Executing from the docker container without direnv
You can use the scripts provided in bin/
directly
Testing
Dues aims for very high test coverage. Tests are written using PHPUnit.
The test suite is broken into unit tests and integration tests.
Individual mileage may vary when running integration tests locally, but the suite is designed to be run in a CI environment. CI tests run against a BrainTree sandbox environment configured by TeamGantt.
To run unit tests locally, run composer test:unit
.
To run integration tests locally, run composer test:integration
.
Integration and unit tests are not separated by any kind of file naming convention, but instead they
are grouped together. An integration test should be annotated using a @group
annotation.
Tests are organized by feature in the tests/Feature
directory.
BrainTree tests
In order to ensure a consistent test environment, the Braintree tests are run against a sandbox environment. It is important that "duplicate transaction checking" is disabled. This will allow integrations to run tests with the same data multiple times without unexpected results.
Please see the Braintree documentation for more information on configuring duplicate transaction checking.
Conventions
Dues aims to be consistent in style and type correctness. Code conventions are enforced using PHP_CodeSniffer. The list of conventions can be found
in the .php-cs-fixer.php
file.
Static analysis is perfomed using phpstan. See phpstan.neon for configuration.
There are composer scripts provided for checking conventions and running static analysis.
Note: composer run fix
will automatically fix any CodeSniffer issues that can be fixed automatically. This is not always possible, so it is recommended that composer run check
be run before committing code.