Bento Laravel SDK

Bento is an Email Marketing & Automation Platform for Startups and their team recently created an official Laravel SDK.

If this is your first time hearing of Bento and you are in need of an email marketing service, they do offer a free 30 day trial so you can give it a try.

If you are an existing Bento user then this SDK helps to make it easier to send emails and track events in your Laravel applications. The package provides powerful and customizable APIs that can be used to manage your subscribers, track events, and send transactional emails. Low-level APIs have also been exposed so that you can build fully customizable experiences.

To install the SDK you can run:

composer require bentonow/bento-laravel-sdk

Next, publish your config:

php artisan vendor:publish --tag bentonow

Then add a new mailer definition in config/mail.php:

'bento' => [
  'transport' => 'bento',
],

Lastly, update your .env file to add your Bento API keys:

BENTO_PUBLISHABLE_KEY="bento-publishable-key"
BENTO_SECRET_KEY="bento-secret-key"
BENTO_SITE_UUID="bento-site-uuid"
MAIL_MAILER="bento"

As an example of its use, if you wanted to add a new subscriber to your account you could use the following code:

use Bentonow\BentoLaravel\Facades\Bento;
use Bentonow\BentoLaravel\DataTransferObjects\CreateSubscriberData;

$data = collect([
  new CreateSubscriberData(email: "This email address is being protected from spambots. You need JavaScript enabled to view it.")
]);

return Bento::createSubscriber($data)->json();

And when you need to find a particular subscriber, you could use the following:

use Bentonow\BentoLaravel\Facades\Bento;

return Bento::findSubscriber("This email address is being protected from spambots. You need JavaScript enabled to view it.")->json();

There is a lot more you can do with this package and we hope to do a follow up tutorial to demonstrate more soon. Until then learn more about this package by reading the documentation and view the source code on Github.


The post Bento Laravel SDK appeared first on Laravel News.

Join the Laravel Newsletter to get all the latest Laravel articles like this directly in your inbox.

Read more

© 2024 Extly, CB - All rights reserved.