Download the PHP package spits-online/laravel-bird without Composer

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

Laravel Bird by Spits

Bird SMS and WhatsApp for Laravel

[![Latest Version on Packagist](https://img.shields.io/packagist/v/spits-online/laravel-bird.svg?style=flat-square)](https://packagist.org/packages/spits-online/laravel-bird) [![Tests](https://img.shields.io/github/actions/workflow/status/Spits-online/laravel-bird/run-tests.yml?branch=main&label=tests&style=flat-square)](https://github.com/Spits-online/laravel-bird/actions/workflows/run-tests.yml) [![PHPStan](https://img.shields.io/github/actions/workflow/status/Spits-online/laravel-bird/phpstan.yml?branch=main&label=phpstan&style=flat-square)](https://github.com/Spits-online/laravel-bird/actions/workflows/phpstan.yml) [![Total Downloads](https://img.shields.io/packagist/dt/spits-online/laravel-bird.svg?style=flat-square)](https://packagist.org/packages/spits-online/laravel-bird)

Notification channels for Bird (formerly MessageBird), plus a small client for the contacts in your workspace.

Requirements

Installation

Add your credentials to .env. Only the channels you use need an id.

You'll find these in Bird:

That's all the configuration most apps need, so you don't have to publish a config file. When you do want to change something, such as package defaults key by key, so everything you leave out keeps its default:

Don't copy keys at their default value. A copied default looks like a deliberate choice, and it stops following the package when the default changes. To see every option, you can publish the full file with php artisan vendor:publish --tag="bird-config". Keep the keys you change and delete the rest.

Using another workspace

The facade uses the workspace in your config. Build a client for another one with fromConfig(), which takes the same keys:

Bird::fake() only replaces the client behind the facade. A client you build with fromConfig() still calls Bird, so fake its requests in your tests with Http::fake().

Sending notifications

Choosing the recipient

The channels send to whatever routeNotificationForBird() on your notifiable returns: a phone number in international format, or an array of them to send to several people.

To send to someone else, set the recipient on the message (->to('+31612345678')), or send an on-demand notification:

to() takes several recipients at once. A value with an @ is sent as an email address, anything else as a phone number, the way Identifier::from() reads it. You can also pass an Identifier:

bird is the route name both Bird channels read, like mail for the mail channel. A phone number is the same for SMS and WhatsApp, so you set it once, and the notification's via() still decides which channels send.

SMS

Add SmsChannel to via() and return an SmsMessage from toBirdSms(), as in the example at the top.

WhatsApp

To start a WhatsApp conversation you need a template approved in Bird Studio. Add WhatsAppChannel to via() and return a WhatsAppMessage from toBirdWhatsApp():

The template's parameters are the variables you defined in Bird Studio. Each value is sent with a matching type: a boolean as boolean, an int or float as number, an array as object, and everything else as string. The version defaults to latest; pass version: to pin one.

Naming templates

To avoid repeating project ids, give your templates a name in your app's config/bird.php. Each entry needs a project_id. version (default latest) and locale are optional:

version pins a template version instead of using the latest.

Then use them by name:

Inside WhatsApp's 24-hour service window you can also send any other message body Bird supports:

SMS and WhatsApp together

A notification can use both channels. Each one calls its own method:

Sending without a notification

Pass a channelId to send through a channel other than the configured one: Bird::send($message, channelId: '…').

Managing contacts

upsert() creates the contact, or updates the one with this phone number or email address. Pass an Identifier::email() to match on the email address:

Contacts are listed a page at a time:

Error handling

Every exception extends SpitsOnline\Bird\Exceptions\BirdException:

Exception When
RequestFailed Bird returned an error. $status, $errorCode and $body hold what Bird sent back.
ConnectionFailed Bird couldn't be reached.
MissingConfiguration An env value is missing, or Template::named() gets a name that isn't in config/bird.php. The message says what to set.
InvalidRecipient A notification has no recipient.
BirdException A notification uses a channel but doesn't have its toBirdSms() or toBirdWhatsApp() method.

A 404 status means the contact doesn't exist.

When a channel throws, Laravel fires its NotificationFailed event. For queued notifications, the job is retried as usual.

Testing your app

Bird::fake() records messages instead of sending them:

Bird::sent() returns the sent messages themselves, optionally filtered:

A message tells you who it goes to and what Bird would receive:

Contact calls go through Laravel's HTTP client, so fake them with Http::fake().

Testing

Changelog

Please see UPGRADE.

Contributing

Please see CONTRIBUTING for details.

Security vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Credits

License

The MIT License (MIT). Please see License File for more information.


All versions of laravel-bird with dependencies

PHP Build Version
Package Version
Requires php Version ^8.3
illuminate/contracts Version ^12.0||^13.0
illuminate/http Version ^12.0||^13.0
illuminate/notifications Version ^12.0||^13.0
illuminate/support Version ^12.0||^13.0
spatie/laravel-package-tools Version ^1.16
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 spits-online/laravel-bird contains the following files

Loading the files please wait ...