andriichuk/laravel-atompark-sms-channel

This is my package laravel-atompark-sms-channel

Maintainers

Package info

github.com/andriichuk/laravel-atompark-sms-channel

pkg:composer/andriichuk/laravel-atompark-sms-channel

Fund package maintenance!

andriichuk

Statistics

Installs: 0

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

0.1.0 2026-03-11 18:57 UTC

This package is auto-updated.

Last update: 2026-03-11 19:15:44 UTC


README

Latest Version on Packagist GitHub Tests Action Status GitHub Code Style Action Status Total Downloads

This package makes it easy to send SMS notifications using AtomPark from your Laravel application, using Laravel's built-in notification system.

Sending an SMS to a user becomes as simple as using:

$user->notify(new YourNotification());

Contents

  • Installation
    • Setting up the AtomPark service
  • Usage
    • Sending text messages
      • Available message methods
  • Testing
  • Changelog
  • Contributing
  • Security
  • License

Installation

You can install the package via composer:

composer require andriichuk/laravel-atompark-sms-channel

The service provider will be auto-discovered by Laravel.

Setting up the AtomPark service

Add your AtomPark SMS credentials to the services.php config file:

// config/services.php

return [
    // ...

    'atompark' => [
        'sms' => [
            'sender' => env('ATOMPARK_SMS_SENDER'),
            'public_key' => env('ATOMPARK_SMS_PUBLIC_KEY'),
            'private_key' => env('ATOMPARK_SMS_PRIVATE_KEY'),
        ],
    ],
];

Then add the corresponding environment variables to your .env:

ATOMPARK_SMS_SENDER="Your Sender Name"
ATOMPARK_SMS_PUBLIC_KEY="your-public-key"
ATOMPARK_SMS_PRIVATE_KEY="your-private-key"

Usage

Notifiable model

In your notifiable model (typically User), add the routeNotificationForAtomPark method that returns a full mobile number including country code:

use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;

class User extends Authenticatable
{
    use Notifiable;

    public function routeNotificationForAtomPark(): string
    {
        return $this->phone; // e.g. +380991112233
    }
}

Notification class

Within your notification, add the AtomPark channel to the via method and implement toAtomPark to build the SMS message:

use Andriichuk\AtomParkSmsChannel\AtomParkChannel;
use Andriichuk\AtomParkSmsChannel\Sms;
use Illuminate\Notifications\Notification;

class Invitation extends Notification
{
    public function via($notifiable): array
    {
        return ['atompark'];
        // or: return [AtomParkChannel::class];
    }

    public function toAtomPark($notifiable): Sms
    {
        return new Sms(
            text: 'You have been invited!',
            phone: $notifiable->routeNotificationForAtomPark(),
            lifetime: 1, // 0 = maximum, 1/6/12/24 hours
        );
    }
}

Now you can send an SMS notification to a user:

$user->notify(new Invitation());

Anonymous notifications

You can also send SMS messages to phone numbers that are not associated with a notifiable model:

use Illuminate\Support\Facades\Notification;

Notification::route('atompark', '+380991112233')
    ->notify(new Invitation());

Your toAtomPark method will receive an AnonymousNotifiable instance, and you can resolve the phone number using:

public function toAtomPark($notifiable): Sms
{
    $phone = method_exists($notifiable, 'routeNotificationFor')
        ? $notifiable->routeNotificationFor('atompark')
        : (string) $notifiable;

    return new Sms(
        text: 'You have been invited!',
        phone: $phone,
    );
}

Available message options

The Sms value object supports:

  • text (string) – the message body.
  • phone (string) – recipient phone number including country code.
  • lifetime (int) – message lifetime in hours (0 = maximum, 1, 6, 12, 24).

Testing

Run the test suite with:

composer test

Changelog

Please see CHANGELOG for more information on what has changed recently.

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.