- How do I install getbrevo/brevo-php in a Laravel application?
- Install it with Composer using composer require getbrevo/brevo-php. The package requires PHP 8.1 or newer, so confirm your Laravel version and runtime meet that constraint. In Laravel, bind the Brevo client as a singleton in a service provider so it can be resolved from the container. Keep API keys in environment variables or a secrets manager rather than in code.
- Is getbrevo/brevo-php compatible with Laravel 10 and Laravel 11?
- Yes, it is a standard Composer package with no framework lock-in, so it works with Laravel versions that support PHP 8.1 or newer. Laravel 10 and 11 both meet that requirement. You integrate it through the service container, facades, jobs, or your own service classes. Check your exact PHP and Laravel patch versions before rollout.
- How do I send transactional email with the Brevo PHP SDK in Laravel?
- Use the SDK's email service client to build a typed request containing the sender, recipients, subject, and HTML or text content, then call the appropriate send method. Wrap the call in a try/catch block so Brevo API exceptions can be logged and handled cleanly. Because the SDK is regenerated between major versions, verify exact method and request class names against the API reference for your installed version.
- How should I handle Brevo API authentication and API keys in Laravel?
- Store Brevo API keys in .env or a secrets manager and pass them into the client at construction time. The authentication documentation has been updated across major versions, so confirm the current key format, header construction, and any new scopes before upgrading. Never log the API key, and redact authorization headers in request logging. For Laravel, resolve the configured client from the container rather than reading env values throughout your code.
- What breaks when upgrading getbrevo/brevo-php from v5 to v6?
- v6 is a major release, so expect renamed namespaces, changed method signatures, and regenerated model and payload shapes. The release includes a v5 to v6 upgrade guide, which should be the first place to check exact breaking changes. Plan code-level rework rather than a simple composer update, and audit every call site that touches SDK models directly. Also rebuild mocked HTTP fixtures because regenerated request and response shapes can invalidate existing tests.
- How do I configure retries and timeouts for Brevo API calls?
- The SDK documents retries and timeouts as advanced client configuration, so set them when constructing the client or custom HTTP client. Use conservative retry counts with backoff, and avoid retrying non-idempotent operations unless your application can safely handle duplicates. In Laravel, combine SDK-level retries with queue-level retries and failed-job handling for a complete strategy. Re-test timeout behavior after any major SDK upgrade.
- How can I test Brevo API integrations in Laravel without calling the real API?
- Use a custom HTTP client or mock handler supported by the SDK to return canned Brevo responses in feature tests. Do not rely on live API calls in CI, and keep fixtures aligned with the SDK major version you are using. Because v6 is regenerated, existing v5 mocked request and response fixtures may need to be rebuilt. Assert both successful responses and SDK exception paths so error handling is covered.
- Can I use Laravel queues and rate limiting with the Brevo PHP SDK?
- Yes, dispatch Brevo API calls from queued jobs so slow or rate-limited requests do not block web requests. The SDK itself does not replace application-level rate limiting, so use Laravel queue throttling, middleware, or backoff strategies for Brevo API limits. Handle 429 and transient errors through retries with sensible delays. Test queue behavior after major SDK upgrades because request payload shapes may change.
- How do I log Brevo API requests and handle SDK exceptions?
- The SDK provides built-in exception handling and documented logging configuration, so catch SDK exceptions at your service boundary and report them through Laravel's exception handler. Log useful context such as endpoint, status code, and correlation ID, but redact API keys, tokens, and recipient PII. Use a custom client if you need deeper request and response logging. Review logging redaction whenever authentication changes in a major release.
- Should I use this official Brevo SDK or a Laravel-specific wrapper package?
- This is the official Brevo PHP SDK, which makes it the safest default for long-term API coverage and support. Community Laravel wrappers can be convenient but often lag behind major SDK releases and may hide breaking changes. A small application service class plus a container binding usually gives you the Laravel ergonomics you need without adding another dependency. If you prefer a Laravel-native HTTP abstraction, evaluate whether losing generated typed models is acceptable.