Download the PHP package bmatovu/laravel-ussd without Composer

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

License Unit Tests Code Quality Code Coverage Documentation

Table of Contents

Overview

Effortlessly construct intricate USSD menus with streamlined efficiency by replacing convoluted nests of PHP files with the simplicity of XML-based menu construction. This approach allows for seamless execution similar to standard PHP scripts, minimizing code complexity and enhancing readability.

Let's explore an example of a simple SACCO USSD application.

Getting started

Installation

Publishables

Usage

Example

menus/menu.xml

app/Http/Controller/UssdController.php

routes/api.php

See more examples in the demo repo

Menu validation

The Schema

You can publish the default schema with the following command:

To ensure your menu files conform to the schema, you can validate them with the following command:

VSCode integration

For real-time XSD validations and suggestions, you can use the RedHat XML extension in Visual Studio Code. This extension provides helpful features for working with XML schemas, including syntax highlighting and validation.

Simulator

The package includes a CLI USSD simulator that supports several popular aggregators.

To get started, publish the simulator configuration file and update it with your aggregator and USSD service endpoint.

Usage:

Aggregators

If your aggregator is not listed, you can request its addition by contacting us or by submitting a pull request.

Constructs

Variable

Note: This tag has no output

Question

Response

Note: this tag throws a FlowBreakException to mark a break in the normal flow.

Options

Options are like named grouped if, else-if statements that allow a user to navigate to a predefined path.

Disable backward navigation

By default, a 0) Back option is added to the rendered options. To disable this behaviour, use the noback attribute.

Note: Top-level options should use the noback attribute as there’s no previous level to return to.

If

It can contain any other tags, including nested <if> tags.

Choose

This construct is intended to handle scenarios typically covered by if, else if, else, and switch statements.

Example #1

Example #2

Example #3

Action

Action tags enable you to execute more tailored operations.

Arguments

You can provide arguments for these actions either through attributes or by defining variables.

Getting user input

When the text attribute is included in an action tag, it prompts the user for input in the same way that a <question> tag would.

List

Lists are designed to show dynamic items.

To use this feature, your provider must supply a list where each item includes both an id (a unique identifier) and a label (the text displayed to the user).

Accessing the selected item on the list

Note: Similar to actions, you can pass arguments to lists via attributes or as variables.

Advanced

Exceptions

The <response> tag throws a FlowBreakException which MUST be handled in your controller to manage the flow of the USSD interaction.

Additionally, you can catch other exceptions and optionally translate them into user-friendly messages, as demonstrated below...

resources/lang/en.json

Note: To minimize logging, the FlowBreakException should not be reported by your application. Ref

Retries

You can also configure the number of retry attempts and specify a custom error message.

Question

Using regex patterns.

Options & Lists

Validation can also be performed based on the available options in the list.

Note: Using retries in <action> tags is not recommended because these tags do not have visibility into the context provided by preceding tags.

Comparisons

The <if> and <when> tags support various types of comparisons.

If a comparison condition (cond) is not specified or is unsupported, the default comparison is eq (equals)

Type Conditions
Numbers - lt
- gt
- lte
- gte
- eq
- ne
- btn
Strings - str.equals
- str.not_equals
- str.starts
- str.ends
- str.contains
Regex - regex.match
Arrays - arr.in
- arr.not_in
Dates - date.equals
- date.before
- date.after
- date.between
Time - time.equals
- time.before
- time.after
- time.between

Localization

Create translation files within your project and reference the keys in your menu files. Here’s an example:

menus/menu.xml

resources/lang/fr.json

USSD simulation

Note:

Cache

This package stores USSD session data in the cache. Each key is prefixed with the session_id and will automatically expire based on the configured ttl (time-to-live).

Accessing variables

Reusing existing variables

Parser

Save default variables

Here's an example of how to save a variable from an incoming USSD request:

Use custom menu entry point

By default, parsing begins at the first element in your menu file, which corresponds to /menu/*[1].

If you want to start parsing from a different point or use a custom menu structure, you can specify the entry point in your code:

See: xpath playground

Simulation

You can enhance the USSD simulator by adding your preferred aggregator.

To do this, register the aggregator in the simulator configuration file. Ensure that the provider class implements the Bmatovu\Ussd\Contracts\Aggregator interface.

simulator.json

JSON

XML is often preferred for constructing configurations that resemble programming logic due to its robust schema validation capabilities and its clear, hierarchical structure. XML’s format is particularly useful for complex configurations and data structures, as it maintains readability and provides straightforward validation against defined schemas.

Testing

To run the package's unit tests, run the following command:

Alternatives


All versions of laravel-ussd with dependencies

PHP Build Version
Package Version
Requires php Version ^8.1
nesbot/carbon Version ^2.3|^3.0
illuminate/container Version ^10.0|^11.0
illuminate/contracts Version ^10.0|^11.0
illuminate/support Version ^10.0|^11.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 bmatovu/laravel-ussd contains the following files

Loading the files please wait ....