PHPackages                             starnerz/laravel-daraja - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. starnerz/laravel-daraja

ActiveLibrary[API Development](/categories/api)

starnerz/laravel-daraja
=======================

A laravel package for the Safaricom Daraja APIs.

v4.0.0(5y ago)77775MITPHPPHP ^7.3CI failing

Since Mar 23Pushed 4y ago3 watchersCompare

[ Source](https://github.com/starnerz/laravel-daraja)[ Packagist](https://packagist.org/packages/starnerz/laravel-daraja)[ RSS](/packages/starnerz-laravel-daraja/feed)WikiDiscussions master Synced 2w ago

READMEChangelog (3)Dependencies (5)Versions (11)Used By (0)

Laravel Daraja
==============

[](#laravel-daraja)

[![styleci](https://camo.githubusercontent.com/552d809336103137c1d7f108eb66c416b4deb7428ce56b2fe678a4e5010a32b9/68747470733a2f2f7374796c6563692e696f2f7265706f732f3132363337363437382f736869656c64)](https://styleci.io/repos/126376478)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/390097903de1eeaf6edb31f80291595a71be055787da3c3409708fe9eb877472/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f737461726e65727a2f6c61726176656c2d646172616a612f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/starnerz/laravel-daraja/?branch=master)[![Packagist](https://camo.githubusercontent.com/a4bc754a7701acae0cd0f48ce166bf9fc63339567d23b9b9481d85ecad84c707/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f737461726e65727a2f6c61726176656c2d646172616a612e737667)](https://packagist.org/packages/starnerz/laravel-daraja)[![Packagist](https://camo.githubusercontent.com/718668ff5d687708ad74aa803e4e84972705ae05e7b0cde58596af4a75938f9e/68747470733a2f2f706f7365722e707567782e6f72672f737461726e65727a2f6c61726176656c2d646172616a612f642f746f74616c2e737667)](https://packagist.org/packages/starnerz/laravel-daraja)[![Packagist](https://camo.githubusercontent.com/c8a05d1dde4996cb80ab8acabb93b404375b19230ca1cf7464126f2afdad70aa/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f737461726e65727a2f6c61726176656c2d646172616a612e737667)](https://packagist.org/packages/starnerz/laravel-daraja)

This package provides you with a simple tool to make requests to Safaricom Daraja APIs so that you can focus on the development of your awesome applications instead of all the set up involved.

Installation
------------

[](#installation)

Install via composer

```
composer require starnerz/laravel-daraja
```

### Register Service Provider

[](#register-service-provider)

**Note! This and next step are optional if you use laravel&gt;=5.5 with package auto discovery feature.**

Add service provider to `config/app.php` in `providers` section

```
Starnerz\LaravelDaraja\LaravelDarajaServiceProvider::class,
```

### Register Facade

[](#register-facade)

Register package facade in `config/app.php` in `aliases` section

```
Starnerz\LaravelDaraja\Facades\MpesaApi::class,
```

### Publish Configuration File

[](#publish-configuration-file)

```
php artisan vendor:publish --provider="Starnerz\LaravelDaraja\LaravelDarajaServiceProvider" --tag="config"
```

Fill in all the details you will be requiring for your application. Here are the env variables for quick copy paste.

```
DARAJA_CONSUMER_KEY=
DARAJA_CONSUMER_SECRET=

DARAJA_INITIATOR_NAME=
DARAJA_INITIATOR_CREDENTIAL=
DARAJA_INITIATOR_SHORTCODE=

DARAJA_STK_SHORTCODE=
DARAJA_STK_PASS_KEY=

```

Usage
-----

[](#usage)

If you have not created your Safaricom API application yet you can create one at [Safaricom Developer](https://developer.safaricom.co.ke/)

Each Safaricom API except Oauth has been implemented as a class on its own which you can use in your code.

```
$STK = new STK();
$STK->push('254727123456','10000','New Purchase','R3F3R3NC3');
```

If you prefer using the facade

```
MpesaApi::STK()->push('254727123456','10000','New Purchase','R3F3R3NC3');
```

If you will be using the C2B Api you can easily register the validation and confirmation URLs through artisan.

```
# php artisan daraja:register-urls
```

Security
--------

[](#security)

If you discover any security related issues, please email instead of using the issue tracker.

###  Health Score

33

—

LowBetter than 72% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity21

Limited adoption so far

Community14

Small or concentrated contributor base

Maturity64

Established project with proven stability

 Bus Factor1

Top contributor holds 93.1% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~129 days

Recently: every ~157 days

Total

8

Last Release

2118d ago

Major Versions

v1.0.4 → v2.0.02020-09-10

v2.0.0 → v3.0.02020-09-10

v3.0.0 → v4.0.02020-09-10

PHP version history (3 changes)v1.0.0PHP &gt;=5.6

v2.0.0PHP ^7.2

v4.0.0PHP ^7.3

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/15049451?v=4)[Stanley Kimathi](/maintainers/starnerz)[@starnerz](https://github.com/starnerz)

---

Top Contributors

[![starnerz](https://avatars.githubusercontent.com/u/15049451?v=4)](https://github.com/starnerz "starnerz (27 commits)")[![edlugz](https://avatars.githubusercontent.com/u/4479919?v=4)](https://github.com/edlugz "edlugz (1 commits)")[![StyleCIBot](https://avatars.githubusercontent.com/u/11048387?v=4)](https://github.com/StyleCIBot "StyleCIBot (1 commits)")

---

Tags

daraja-apilaravel-mpesampesa-apilaravelmpesampesa-apidaraja

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/starnerz-laravel-daraja/health.svg)

```
[![Health](https://phpackages.com/badges/starnerz-laravel-daraja/health.svg)](https://phpackages.com/packages/starnerz-laravel-daraja)
```

###  Alternatives

[craftcms/cms

Craft CMS

3.6k3.6M2.9k](/packages/craftcms-cms)[tempest/framework

The PHP framework that gets out of your way.

2.2k31.1k12](/packages/tempest-framework)[smodav/mpesa

M-Pesa API implementation

16167.1k1](/packages/smodav-mpesa)[simplestats-io/laravel-client

Analytics for Laravel. Track visitors, registrations, and payments. Discover which channels actually drive revenue, not just traffic. Server-side, GDPR compliant, ad-blocker proof.

5019.3k](/packages/simplestats-io-laravel-client)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
