Skip to main content

Installation Methods

The Mangopay PHP SDK can be installed using Composer (recommended) or manually. Choose the method that best fits your project setup. Composer is the recommended installation method as it automatically handles dependencies, including the required PSR Log library.
1

Install Composer

If you don’t have Composer installed, follow the official installation instructions.
2

Add the Mangopay SDK Dependency

Run the following command in your project directory:
composer require mangopay4/php-sdk
This command adds the Mangopay SDK to your composer.json file and downloads the package.
3

Update Dependencies

Update your dependencies to ensure all requirements are met:
composer update
4

Include the Autoloader

In your PHP code, include Composer’s autoloader:
require_once '/path/to/your-project/vendor/autoload.php';
The SDK is available on Packagist as mangopay4/php-sdk.

Verifying Composer Installation

After installation, verify that the SDK is available:
require_once 'vendor/autoload.php';

use MangoPay\MangoPayApi;

$api = new MangoPayApi();
echo "Mangopay SDK installed successfully!";

Manual Installation

If you’re not using Composer, you can install the SDK manually. However, you’ll need to manage dependencies yourself.

Option 1: Using PSR-4 Autoloader

The SDK complies with PSR-4 autoloading standards with namespace prefix MangoPay\ and base directory at your project root.
1

Download the SDK

Download the SDK from the GitHub repository.
2

Place in Your Project

Extract the SDK to your project directory, ensuring the MangoPay folder is accessible.
3

Include the Autoloader

Use the SDK’s built-in autoloader:
require_once '/path/to/your-project/MangoPay/Autoloader.php';
When using manual installation with the PSR-4 autoloader, you must manually install the psr/log dependency.

Option 2: Complete Package with Dependencies

For a simpler manual installation that includes all dependencies:
1

Download the Complete Package

Go to the Releases page and download the mangopay2-php-sdk-[RELEASE_NAME].zip file.
2

Extract the Archive

Uncompress the ZIP file to your desired location.
3

Include the Autoloader

The package includes a vendor directory with all dependencies:
require_once '/path/to/your-project/mangopay2-php-sdk/vendor/autoload.php';
This method is ideal if you cannot use Composer but still want all dependencies bundled together.

Comparing Installation Methods

FeatureComposerManual (PSR-4)Manual (Complete)
Dependency ManagementAutomaticManualIncluded
UpdatesEasy via composer updateManual downloadManual download
Setup ComplexityLowMediumLow
Recommended✅ YesOnly if neededAlternative

Post-Installation Steps

After installation, you’re ready to configure the SDK:

Configuration

Set up your API credentials and environment settings

Quick Start

Create your first user and make your first API call

Troubleshooting

Authentication Issues After SDK Update

If you experience authentication problems or temporary token file issues after updating the SDK (particularly to v2.0), delete your temporary token file:
# Delete the temporary folder contents (adjust path as needed)
rm -rf /tmp/mangopay/*
The token file will be regenerated correctly on the next API request.

Missing Dependencies

If you encounter errors about missing classes or namespaces:
composer install
composer dump-autoload

Next Steps

With the SDK installed, proceed to configuration to set up your API credentials and start building your integration.

Build docs developers (and LLMs) love