speso / laravel-ussd
Create ussd with ease
Requires
- php: ^8.0
- illuminate/support: ~8|~9|~10|~11|~12|~13
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.41
- orchestra/testbench: ~6|~7|~8|~9|~10|~11
- phpunit/phpunit: ^9.6|^10.0|^11.0
This package is auto-updated.
Last update: 2026-08-02 18:55:28 UTC
README
Build Ussd (Unstructured Supplementary Service Data) applications with laravel without breaking a sweat.
Features
- Menus as classes — define screens as
Stateclasses with a fluentMenubuilder, and route between them declaratively with#[Transition]attributes. - Built-in decisions — match input with
Equal,Between,In,Regex,IsNumericand more out of the box; scaffold custom ones withussd:decision. - Conditional branching —
Actionclasses decide the next state at runtime (e.g. after an HTTP call), for flows that can't be expressed as static attributes. - Back navigation — a
#[Back]attribute with an automatic per-session history stack, no manual bookkeeping. - Automatic pagination — the
WithPaginationtrait plus a#[Paginate]attribute page long listings without manual bookkeeping. - Response truncation — a
#[Truncate]attribute caps how many characters a screen returns, so dynamic content can't blow past your gateway's character limit. - Resumable sessions —
useContinuingState()lets a redial pick back up where a timed-out session left off, silently or after confirming with the user. - Configurators — group and share repeated setup (response format, exception handling, etc.) across controllers.
- Localized menus — build menu content from translation files, and persist a session's chosen language across requests.
- Session records — a
RecordAPI (get/set/increment/decrement/...) for persisting data during a session, with optional cross-session persistence viapublic: true. - Encrypted session data — store sensitive values (PINs, account numbers) encrypted at rest in the session
Record. - Built-in gateway responses — ships
Responseclasses for Speso, AfricasTalking, Nsano, Nalo, Moolre and Arkesel; scaffold your own for anything else. - Exception handling — implement
ExceptionHandlerto turn an unhandled exception into a message the caller sees, instead of a dead session. - Flow visualization —
ussd:graphrenders a Mermaid state diagram of a flow straight from its attributes. - Interactive simulation —
ussd:simulatelets you walk a flow in the terminal like a real handset, no gateway or phone required. - Flow linting —
ussd:lintcatches dead ends, broken transitions, duplicate matches and unreachable states before they ship. - Testing utilities — a fluent
Ussd::test()API for asserting screens, context, and session state across multi-step conversations. - Session events —
StateEnteredandSessionTerminatedevents for logging or analytics, without touching core classes. - Artisan generators — scaffold states, actions, responses, decisions, configurators and exception handlers with commands like
ussd:stateandussd:action.
Installation
You can install the package via composer:
composer require speso/laravel-ussd:^3.0
For older version use
composer require speso/laravel-ussd:^2.0
Upgrading from sparors/laravel-ussd
As of v3.0.0, this package is published as speso/laravel-ussd under the Speso\Ussd namespace. If you're on an older sparors/laravel-ussd install, upgrading requires two steps:
- Swap the composer dependency:
composer remove sparors/laravel-ussd composer require speso/laravel-ussd:^3.0
- Find and replace
Sparors\UssdwithSpeso\Ussdacross your application (usestatements, service provider references, configvendor:publishcalls, etc.). There are no other API or behavior changes in this release, so no further code changes are required.
Documentation
See the documentation.
Change log
Please see the changelog for more information on what has changed recently.
Contributing
Please see contributing.md for details and a todolist.
Security
If you discover any security related issues, please email services@speso.co instead of using the issue tracker.
Credits
Special thanks to Isaac Sai for writing this package.
License
MIT. Please see the license file for more information.