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.
Download gantry-motion/ussd-monkey
More information about gantry-motion/ussd-monkey
Files in gantry-motion/ussd-monkey
Package ussd-monkey
Short Description Easily build USSD Applications
License MIT
Informations about the package ussd-monkey
USSD Monkey
The USSD Monkey package is designed to help developers quickly build USSD applications by defining their menu flow in a JSON file. This README.md file provides documentation on how to use the package effectively. This package uses Redis to temporarily store session information.
Installation
To install the USSD Monkey package, you can use Composer:
Usage
After installing the package, you need to configure it by providing the path to your USSD menu JSON file and specifying a custom class namespace if needed. Here's an example configuration:
Then, instantiate the USSD Monkey class and call the push
method to render the content of your application menu:
The push
method takes two arguments: the parameters sent by your USSD gateway (such as session ID, service code, phone number, and request string) and the default menu to display.
Configuration
The package comes with default configuration settings, but you can override them as needed. Here are some of the key configuration options:
environment
: Set the environment to "production" or "development".input_format
: Define the input format. Accepted value: "chained".output_format
: Determine the output format. Accepted values: "conend" or "json".enable_chained_input
: Enable or disable chained input if supported by the USSD gateway provider. Accepted values: "true" or "false".enable_back_and_forth_menu_nav
: Enable or disable back and forth menu navigation. Accepted values: "true" or "false".chars_per_line
: Specify the number of characters per line.menu_items_separator
: Define the separator for menu items (| or ,).nav_next
: Define the navigation string for moving to the next menu.nav_prev
: Define the navigation string for moving to the previous menu.sanitizePhoneNumber
: Enable or disable phone number sanitization. Accepted values: "true" or "false".error_title
: Set the title for error messages.error_message
: Set the default error message.disabled_func
: List any disabled functions from your project to be marked as suspended during USSD usage.request_variables
: Map request variables to their corresponding names as sent by the USSD Gateway provider (session id, service code, phone number, request string).redis
: Configuration settings for Redis.
You can override these settings by providing a custom configuration array when instantiating the USSD Monkey class.
To view the configuration that USSD Monkey will use, you can utilize the configInfo()
function provided by the package. Here's how you can use it:
This code will output a JSON representation of the current configuration settings that USSD Monkey will use for your USSD application. You can then inspect these settings to ensure they align with your requirements.
Example
Here's an example of how you might instantiate the USSD Monkey class with custom configuration:
Below is an example of the ussdMenu.json
file structure:
This JSON structure defines the menu options for your USSD application. Each menu item has a display label and, optionally, an associated action to execute (_EXECUTE_
). The structure supports nested options for creating multi-level menus. Ensure your ussdMenu.json
file adheres to this format to work correctly with USSD Monkey.
Below is an example of the USSD
PHP class containing custom methods for your USSD application:
This USSD
class contains methods that correspond to the actions defined in your ussdMenu.json
file. These methods process the data received from the USSD menu and return appropriate responses. Ensure that the namespace and class name match the ones specified in your configuration.
That's it! You're now ready to use the USSD Monkey package to build your USSD applications.