2017 © Pedro Peláez
 

library notifire-bundle

image

fazland/notifire-bundle

  • Thursday, July 26, 2018
  • by alekitto
  • Repository
  • 4 Watchers
  • 3 Stars
  • 3,757 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 1 Open issues
  • 5 Versions
  • 7 % Grown

The README.md

Notifire Bundle

Build Status, (*1)

Notifire Bundle provides integration of Notifire library into the Symfony Framework., (*2)

Notifire is a PHP library that centralizes the management of notifications (e-mails, sms, push notifications, etc.), check its GitHub page to learn more., (*3)

Requirements

  • php >= 7.0
  • symfony/symfony >= 2.8
  • fazland/notifire

Installation

The suggested installation method is via composer:, (*4)

$ composer require fazland/notifire-bundle

Using Notifire Bundle

First of all, register NotifireBundle in your AppKernel.php:, (*5)

public function registerBundles()
{
    return [
        // ...
        new NotifireBundle(),
        // ...
    ];
}

The configuration of Notifire Bundle is simple, just include in your app/config/config.xml (or equivalent) something like the following:, (*6)

<notifire:config>
    <notifire:email auto_configure_swiftmailer="true">
        <notifire:mailer name="mailgun_example"
            provider="mailgun" api_key="api_key" domain="example.org" />
    </notifire:email>
    <notifire:sms>
        <notifire:service name="default_sms" provider="twilio"
                          username="%twilio_account_sid%"
                          password="%twilio_auth_token%"
                          sender="%twilio_from_phone%" />
    </notifire:sms>
</notifire:config>

YAML version:, (*7)

notifire:
    email:
        auto_configure_swiftmailer: true
        mailers:
            mailgun_example:
                provider: mailgun
                api_key: api_key
                domain: example.org
    sms:
        services:
            default_sms:
                provider: twilio
                account_sid: '%twilio_account_sid%'
                auth_token: '%twilio_auth_token%'
                from_phone: '%twilio_from_phone%'

This configuration snippet registers in Notifire all your existing SwiftMailer's mailers, the specified Twilio's services and Mailgun's mailers., (*8)

If you want to register by instance only a set of SwiftMailer` mailers just use:, (*9)

<!-- ... -->
    <notifire:email auto_configure_swiftmailer="false">
        <notifire:mailer name="y_mail" 
            provider="swiftmailer" mailer_name="%your_mailer%" />
    </notifire:email>
<!-- ... -->

or in YAML:, (*10)

# ...
    email:
        auto_configure_swiftmailer: false
        mailers:
            y_mail:
                provider: swiftmailer
                mailer_name: '%your_mailer%'
# ... 

This configuration will provide Notifire configured and set in your container and its handlers ready to send your notifications!, (*11)

As usual, just create an e-mail with Notifire::email() and send it:, (*12)

// Use 'default' mailer
$email = Notifire::email('default');

$email
    ->addFrom('test@fazland.com')
    ->addTo('info@example.org')
    ->setSubject('Only wonderful E-mails with Notifire!')
    ->addPart(Part::create($body, 'text/html'))
    ->send()
;

Contributing

Contributions are welcome. Feel free to open a PR or file an issue here on GitHub!, (*13)

License

Notifire Bundle is licensed under the MIT License - see the LICENSE file for details, (*14)

The Versions