Download the PHP package gantry-motion/ussd-monkey without Composer

On this page you can find all versions of the php package gantry-motion/ussd-monkey. 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 ussd-monkey

USSD Monkey

USSD Monkey is a small, gateway-agnostic engine for building multi-turn USSD applications from a single JSON menu file. It normalizes requests from different USSD gateways (Africa's Talking, UConnect, DMark, TrueAfrican, or your own) behind a common adapter interface, and uses Redis to track each caller's position in the menu between requests.

Installation

Requires a reachable Redis instance (via predis/predis).

Quick Start

USSDMonkey's constructor takes two arguments: your config array (merged over the library defaults) and a handler instance — typically your controller ($this) — whose public methods are invoked by name whenever the menu hits an execute_func.

setAdapters() activates one or more of the keys registered under available_adapters (see Configuration below) and tries them in order against each incoming request; the first one whose validate() matches wins. run() then parses the request, resolves the caller's position via Redis, and returns the rendered response body already formatted for that gateway.

The Handler Contract

Every execute_func referenced in your menu JSON must exist as a public method on the handler instance you pass to the constructor, with the signature:

The return value controls what happens next:

Return value Effect
string Replaces the current menu node's display text and continues rendering normally
false Re-renders the last screen prefixed with a generic "Invalid Input." notice
$ussd->retry($msg) Re-renders the last screen prefixed with your own custom message instead of the generic one
$ussd->terminate($msg) Ends the session with $msg as the final screen

Every unimplemented execute_func referenced by your menu JSON will fatal with a PHP \Error (undefined method) rather than a catchable \Exception — make sure every execute_func in your menu has a matching handler method before going live.

ussdMenu.json Format

Configuration

Passed as the first constructor argument and merged recursively over the library defaults (config/default.php):

Key Default Purpose
ussd_menu_file null (required) Absolute path to your ussdMenu.json
available_adapters the 4 built-in adapters Map of adapter key → class name; add your own or override a built-in one here
session_ttl 180 Seconds a session's Redis keys survive since the last request. Refreshed on every request while the session is active, so it only expires idle sessions
items_per_page 6 Lines per page before pagination kicks in
menu_items_separator \| Separator splitting a display string into lines
nav_next / nav_prev 0 / 00 Inputs reserved for next-page / previous-page-or-back navigation
sanitization.enabled true Whether incoming phone numbers are normalized
sanitization.country_code 256 Prepended to the sanitized local number. Assumes a single-country deployment — don't enable this if you accept international numbers
sanitization.local_number_length 9 Digits kept from the end of the raw number before prepending country_code
redis {scheme: tcp, host: 127.0.0.1, port: 6379} Passed straight through to Predis\Client
chars_per_line null (disabled) When set, wraps any single display line exceeding this width onto additional lines before pagination is applied

Writing a Custom Adapter

Implement GantryMotion\USSDMonkey\Adapters\AdapterInterface:

Register it under available_adapters with a unique key and pass that key to setAdapters(). Don't call PHP's header() inside formatResponse() — return the content type from getContentType() instead and let the calling app set it on its own response object via $ussd->getContentType(). This keeps the package framework-agnostic and avoids header ordering issues with frameworks (like CodeIgniter) that manage their own response object.

Versioning Note

AdapterInterface requires getContentType() as of 2.0.0. If you're upgrading from 1.x with a custom adapter, add that method before updating — otherwise your adapter will fatal with a "must implement" error.


All versions of ussd-monkey with dependencies

PHP Build Version
Package Version
Requires predis/predis Version ^1.1 || ^2.0 || ^3.0
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 gantry-motion/ussd-monkey contains the following files

Loading the files please wait ...