PHP code example of designbycode / laravel-brevo

1. Go to this page and download the library: Download designbycode/laravel-brevo library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

designbycode / laravel-brevo example snippets


return [
    'api_key' => env('BREVO_API_KEY', ''),
];

use Designbycode\LaravelBrevo\Facades\Brevo;

if ($contact = Brevo::getContactInfo('[email protected]')) {
    echo "Contact Name: " . $contact->getAttributes()->name;
} else {
    echo "Contact not found.";
}

use Designbycode\LaravelBrevo\Facades\Brevo;
if ($success = Brevo::subscribe('[email protected]', $listId)) {
    echo "Contact subscribed successfully!";
} else {
    echo "Failed to subscribe contact.";
}

use Designbycode\LaravelBrevo\Facades\Brevo;

if ($success = Brevo::unsubscribe('[email protected]', $listId)) {
    echo "Contact unsubscribed successfully!";
} else {
    echo "Failed to unsubscribe contact.";
}
bash
php artisan vendor:publish --tag="brevo"