Download the PHP package moonlydays/php-kannel without Composer
On this page you can find all versions of the php package moonlydays/php-kannel. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package php-kannel
PHP Kannel
A PSR-compliant PHP client for the Kannel SMS gateway. Handles outbound SMS via sendsms, bearerbox admin commands, and inbound DLR/MO callback parsing — with typed value objects, enums, and a clean extensibility surface.
Features
- Send SMS via Kannel's
sendsmsHTTP interface (GET or POST) - Bearerbox admin API — typed methods for
status,suspend,resume,shutdown,log-level,add-smsc,remove-smsc, and more - Inbound DLR parsing — PSR-7
ServerRequest→ typedDeliveryReport - Inbound MO parsing — PSR-7
ServerRequest→ typedIncomingMessage - Multi-gateway routing via
GatewayRegistry - PSR-18 HTTP client (Guzzle as the default, swappable)
- PSR-17 factories, PSR-14 events, PSR-3 logging — all optional
- FakeClient test double for consumer-side tests
- Readonly value objects, backed enums, strict types throughout
Requirements
- PHP 8.2+
- A reachable Kannel installation (for sendsms and/or admin)
Installation
Quick start
Configuration
Gateway
Gateway is an immutable value object carrying everything needed to talk to one Kannel installation.
The httpMethod choice is deliberate — the library doesn't pick for you. Use Post when you want credentials out of access logs; Get when Kannel is configured to accept only GET.
Multi-gateway
Single-gateway users don't see the registry — new Client($gateway) normalizes internally.
Swapping the HTTP client
Every PSR dependency is optional. Pass your own to override the Guzzle defaults.
Sending messages
SmsBuilder is the only supported way to construct an Sms. It validates invariants (recipient required, text XOR binary) on build().
Sending results
Delivery reports (DLR)
Configuring dlr-url
Kannel substitutes placeholders (%d, %p, %T, %I, …) in your callback URL before hitting it. The library gives you two ways to build the URL — explicit or via a binding.
Explicit — full control over query key names:
Convention-based — shared with the inbound parser:
The same $binding is then passed to InboundHandler on the receiving side, so the two halves agree on query key names without duplicated string literals.
Receiving DLR callbacks
The handler reads both query params and parsed body, so it works regardless of whether Kannel was configured to POST or GET the callback.
Mobile originated messages (MO)
Admin API
Requires the gateway to have AdminCredentials attached. Each command maps to a typed method.
GatewayStatus exposes version, uptime string, SMS counters, DLR queue depth, a list of SmscStatus and a list of BoxStatus.
Constructing an AdminClient on a gateway without admin credentials throws ConfigurationException.
Events (PSR-14)
Pass any PSR-14 dispatcher to receive events:
| Event | Dispatched by | Fired |
|---|---|---|
MessageSending |
Client::send() |
Before the transport runs |
MessageSent |
Client::send() |
After the transport returns (success or Kannel err) |
MessageFailed |
Client::send() |
When the transport throws |
DlrReceived |
InboundHandler |
After receiveDlr() parses successfully |
MoReceived |
InboundHandler |
After receiveMo() parses successfully |
All events are readonly DTOs carrying the relevant Sms / Gateway / SendResult / DeliveryReport / IncomingMessage.
Logging (PSR-3)
The client emits:
debugwhen a send beginsinfoafter a response is parsederrorwhen the transport throws
Testing
FakeClient is a drop-in ClientInterface implementation that records sends and returns configurable results.
Configure per-gateway failure to test fallback logic:
Running the package's own tests
Exception handling
Every exception thrown by this package implements MoonlyDays\Kannel\Exception\ExceptionInterface, so you can catch them all with one type:
| Exception | Meaning |
|---|---|
TransportException |
HTTP-level failure (network, DNS, TLS) reaching Kannel |
AdminCommandFailedException |
Admin command returned 4xx/5xx |
MalformedResponseException |
status.xml unparseable, DLR missing required keys, unknown status code |
ConfigurationException |
Package misused (no recipient, missing admin creds, etc.) |
GatewayNotFoundException |
Registry lookup failed |
Kannel answering with a non-success status (e.g. 3: Malformed data) is not an exception — it comes back as a SendResult with a non-success SendStatus.
License
MIT — see LICENSE.
All versions of php-kannel with dependencies
psr/http-client Version ^1.0
psr/http-factory Version ^1.0
psr/http-message Version ^1.1 || ^2.0
psr/event-dispatcher Version ^1.0
psr/log Version ^2.0 || ^3.0
guzzlehttp/guzzle Version ^7.8
guzzlehttp/psr7 Version ^2.6