Download the PHP package apelimpesa/mpesa-php without Composer

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

M-Pesa PHP Library

This library provides a simple and flexible way to integrate M-Pesa API services into your PHP application. It supports STK Push, C2B, B2C, transaction status queries, and reversals.


Features


Installation

Install the library via Composer:


Configuration

Step 1: Copy the Example Environment File

The library includes an .env.example file with all required configuration variables. Copy this file to your project root as .env:

Step 2: Configure Your Environment Variables

Edit the .env file with your M-Pesa API credentials and settings:

Step 3: Required Variables

Variable Description Required For
APP_ENV Application environment (development/production) All operations
MPESA_CONSUMER_KEY Your M-Pesa API consumer key All operations
MPESA_CONSUMER_SECRET Your M-Pesa API consumer secret All operations
MPESA_SHORTCODE Your business shortcode All operations
MPESA_PASSKEY Your Lipa Na M-Pesa Online passkey STK Push
MPESA_INITIATOR_NAME B2C/B2B transaction initiator name B2C/B2B
MPESA_INITIATOR_PASSWORD Encrypted initiator password B2C/B2B
MPESA_CERTIFICATE_PATH Path to your M-Pesa certificate (if required) Optional for security

Usage

Step 1: Load Environment Variables

Ensure your application loads the .env file. For non-Laravel projects, use vlucas/phpdotenv:

Step 2: Initialize the Library

Create an instance of the M-Pesa service:

Step 3: Perform Transactions

1. STK Push (Lipa Na M-Pesa Online)

2. Query Transaction Status

3. Reverse a Transaction


Testing with Sandbox

When APP_ENV=development, the library uses M-Pesa's sandbox environment. No real money is transferred during testing.

For production, set:


Security Notes


Requirements


License

This library is open-source and available under the MIT License.


All versions of mpesa-php with dependencies

PHP Build Version
Package Version
Requires php Version >=7.4
guzzlehttp/guzzle Version ^7.0
monolog/monolog Version ^2.9
nesbot/carbon Version ^2.0
vlucas/phpdotenv Version ^5.3
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 apelimpesa/mpesa-php contains the following files

Loading the files please wait ....