nordsoftware/lumen-sparkpost

This package is abandoned and no longer maintained. No replacement package was suggested.

SparkPost module for the Lumen PHP framework.

1.0.0 2017-04-24 10:22 UTC

This package is auto-updated.

Last update: 2023-03-22 06:04:38 UTC


README

Test Coverage Status Code Climate Scrutinizer Code Quality Latest Stable Version Total Downloads License

SparkPost module for the Lumen PHP framework.

Requirements

Setup

Installation

Run the following command to install the package through Composer:

composer require nordsoftware/lumen-sparkpost

Configure

Copy the configuration template in config/sparkpost.php to your application's config directory and modify according to your needs. For more information see the Configuration Files section in the Lumen documentation.

The only required config is the API key, which you can get on your SparkPost account pages. Please note that the default configuration uses synchronous sending mode. If you want to change that, set the async option to true instead.

Bootstrapping

Add the following lines to bootstrap/app.php:

$app->register(Nord\Lumen\SparkPost\SparkPostServiceProvider::class);

Usage

You can now use Nord\Lumen\SparkPost\SparkPostService to access SparkPost anywhere in your application.

public function sendEmail(SparkPostService $sparkpost) {
    $results = $sparkpost->send([
        'from' => [
            'name' => 'From Envelope',
            'email' => 'from@sparkpostbox.com',
        ],
        'recipients' => [
            [
                'address' => [
                    'email' => 'john.doe@example.com',
                ],
            ],
        ],
        'template' => 'my-first-email',
    ]);
}

Contributing

Please read the guidelines.

Running tests

Clone the project and install its dependencies by running:

composer install

Run the following command to run the test suite:

vendor/bin/codecept run unit

License

MIT, see LICENSE.