Bento Laravel SDK
Last updated on by Yannick Lyn Fatt
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: "test@laravel-news.com")]); 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("test@laravel-news.com")->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.