notifea/notifea-php-laravel

Laravel wrapper for PHP language for Notifea services.

1.2.0 2021-05-16 14:51 UTC

This package is auto-updated.

Last update: 2024-05-16 21:01:49 UTC


README

Laravel wrapper for PHP language for Notifea services.

Notifea provides clients very user-friendly way of sending transactional emails and sms to their users.

This package is a Laravel wrapper for Notifea PHP package.

Minimum requirements

This package will require you to use:

Installation

To install the SDK you need to be using Composer in your project. To install it please see the docs.

After you installed Composer install the SDK

composer require notifea/notifea-php-laravel

Don't forget to publish configuration file

php artisan vendor:publish --provider='Notifea\Laravel\Providers\NotifeaServiceProvider'

In the notifea.php config file you are only required to set authorization config key by setting NOTIFEA_API_AUTHORIZATION environment variable. Value can be generated in access-tokens section.

If auto discovery of this package does not work for you for any reason, add Notifea\Laravel\Providers\NotifeaServiceProvider to file config/app.php to the section providers

    'providers' => [
        /*
         * Laravel Framework Service Providers...
         */
        Notifea\Laravel\Providers\NotifeaServiceProvider::class,
    ];

Usage

This packages provides a convenient dependency injection layer for Notifea\Services\EmailService, Notifea\Services\SmsService and Notifea\Services\SmsSenderService implemented in our core Notifea PHP package so they can be easily used anywhere in your Laravel application.

One could inject them like this:

class UserController
{
    public function sendEmail(Request $request, EmailService $emailService)
    {
        // .. your business logic
        $email = new Email();
        // ... 
        $sentEmail = $emailService->sendEmail($email);
    }

    public function sendSms(Request $request, SmsService $smsService)
    {
        // .. your business logic
        $sms = new Sms();
        // ... 
        $sentSms = $smsService->sendSms($sms);
    }
    
    public function createSmsSender(Request $request, SmsSenderService $smsSenderService)
    {
        // .. your business logic
        $smsSender = new SmsSender();
        // ... 
        $createdSmsSender = $smsSenderService->createSmsSender($smsSender);
    }

}

To provide the quick accessibility of the methods anywhere in your code, there is also Notifea\Laravel\Facades\Emails, Notifea\Laravel\Facades\SMS and Notifea\Laravel\Facades\SmsSender facade available to you.

Emails facade contains these methods:

  • getEmails()
  • getEmail(string $emailUuid)
  • sendEmail(Email $email)
  • deleteEmail(string $emailUuid)

SMS facade contains these methods:

  • getSmss()
  • getSms(string $smsUuid)
  • sendSms(Sms $sms)
  • deleteSms(string $smsUuid)

SmsSender facade contains these methods:

  • getSmsSenders()
  • getSmsSender(string $smsSenderUuid)
  • createSmsSender(SmsSender $smsSender)
  • updateSmsSender(SmsSender $smsSender)
  • deleteSmsSender(string $smsSenderUuid)

To find more detailed documentation about each methods, check out our core Notifea PHP package

Community

Contributing

Dependencies are managed through composer:

$ composer install

Tests can be run via phpunit:

$ vendor/bin/phpunit