Download the PHP package omerfayyaz/laravel-sms-gateway without Composer

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

Laravel SMS Gateway client

Send and receive SMS from a Laravel app through an SMS gateway that you host yourself, with Android phones as the modems. The package sends messages, looks them up, sends Laravel notifications as SMS, and turns the gateway's signed webhooks into Laravel events.

Requirements

Install

Add to .env:

Then send yourself a message to check the setup:

To change the timeouts, the retries or the webhook path, publish the config file:

Sending

SmsMessage sets everything else:

The gateway accepts the message and queues it; a phone sends it shortly after. Its outcome arrives later, by webhook.

Idempotency

A request that cannot reach the gateway, or that fails on its side, is tried again, twice by default. Each retry carries the same idempotency key, so the gateway returns the message it already queued instead of sending another. When send() is called again with a key the gateway has seen, it returns that first message with replayed set.

Without a key of your own, each call to send() makes one. That covers the retries within the call, but not a job that runs twice. For those, give the message a key made from what it is for, as in the example above. Queued notifications do this for you.

The gateway remembers a key for good, so a key should name one send, not a recipient: a second reminder under reminder-{$guest->id} would never go out. The same key with another number or text is refused with a 409. Keys are at most 64 characters.

Notifications

Add 'sms-gateway' to the notification's channels, and say what to send:

The number comes from the notifiable:

or is given on demand:

A notifiable without a number is skipped. Each notification is sent with the notification's id as its idempotency key. A queued notification (ShouldQueue) keeps that id when its job is retried, so a retry cannot send the SMS twice. A notification sent straight away gets a new id each time: if the code that sends it can run twice, queue the notification or give the message a key of your own.

Looking messages up

The list holds the app's own messages, and the SMS that arrived for it (to filters by recipient; for an arrived SMS that is the number it arrived on).

Webhooks

The package registers POST /sms-gateway/webhook. The route sits outside the web middleware, so no session or CSRF token is involved; the signature authenticates each event. To set it up:

  1. On the gateway's dashboard, open Apps, then your app, then Webhook.
  2. Enter https://your-app.example/sms-gateway/webhook and pick the events to receive.
  3. Put the signing secret it shows into SMS_GATEWAY_WEBHOOK_SECRET.

Each event becomes a Laravel event:

Gateway event Laravel event Means
message.sent MessageSent A phone handed the message to the network
message.delivered MessageDelivered The carrier confirmed delivery
message.failed MessageFailed It could not be sent; failureReason says why
message.expired MessageExpired It was not sent before it expired
message.received MessageReceived An SMS arrived for the app

Each of these carries $event->message (a GatewayMessage), $event->eventId and $event->occurredAt. Every event, including ones this version doesn't know, also arrives raw as WebhookReceived.

Events arrive at least once, and not always in order:

So make listeners safe to run twice, and use $event->eventId to tell repeats apart. A listener that replies should key its SMS by the event, so a second run sends nothing new:

Queue listeners that do slow work, so the gateway gets its answer quickly.

To register the route yourself, set SMS_GATEWAY_WEBHOOK_PATH=null, then add it where no CSRF check runs, such as routes/api.php. In routes/web.php the CSRF check would refuse every event:

Errors

Everything thrown extends OmerFayyaz\SmsGateway\Exceptions\SmsGatewayException.

After a ConnectionFailed, or a RequestFailed with a 5xx status, the SMS may still have been queued. Both carry the idempotencyKey that was used; sending again with it is safe, because the gateway answers with the message it already has.

Testing

To test your webhook listeners, post an event signed the way the gateway signs it:

License

MIT. See LICENSE.md.


All versions of laravel-sms-gateway with dependencies

PHP Build Version
Package Version
Requires php Version ^8.2
guzzlehttp/guzzle Version ^7.8
laravel/framework Version ^12.18|^13.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 omerfayyaz/laravel-sms-gateway contains the following files

Loading the files please wait ...