SparkPost module for the Lumen PHP framework.
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.github
config
src
tests
.gitignore
.styleci.yml
.travis.yml
LICENSE
README.md
codeception.yml
composer.json
composer.lock

README.md

Lumen SparkPost

Build Status 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.