Laravel Evolution API¶
A production-ready Laravel package for seamless integration with Evolution API - the powerful WhatsApp messaging solution.
Unofficial WhatsApp Integration
This package uses Evolution API, which connects to WhatsApp through the unofficial Baileys library. This is not the official WhatsApp Business API.
Potential Consequences:
- Terms of Service - May violate WhatsApp's ToS
- Account Ban - Your number could be temporarily or permanently banned
- Service Disruption - WhatsApp can block unofficial methods at any time
- No Official Support - Meta/WhatsApp does not support this method
Recommendations:
- Use a dedicated phone number (never your personal number)
- Start with low message volumes and scale gradually
- Avoid spammy behavior - no bulk unsolicited messages
- Have a backup communication channel
- Consider the official WhatsApp Business Platform for critical applications
By using this package, you acknowledge these risks and accept full responsibility.
Why Laravel Evolution API?¶
This package provides everything you need to integrate WhatsApp messaging into your Laravel application with a clean, fluent API.
-
Full API Coverage
Instance management, messaging, groups, profiles, webhooks, and settings - all through a clean Laravel interface.
-
Rich Message Types
Send text, images, videos, audio, documents, locations, contacts, polls, lists, buttons, and reactions.
-
Queue Support
Send messages asynchronously with Laravel's queue system for better performance and reliability.
-
Webhook Processing
Built-in webhook controller with signature verification and extensible event handlers.
-
Rate Limiting
Configurable rate limits to respect API constraints and prevent throttling.
-
Metrics & Logging
Track message counts, API calls, and errors with multiple driver support.
-
Database Models
Eloquent models for instances, messages, contacts, and webhook logs with automatic tracking.
-
Testing Utilities
Fake implementation with fluent assertions for unit testing your application.
Quick Installation¶
Add your Evolution API credentials to .env:
EVOLUTION_API_BASE_URL=https://your-evolution-api-server.com
EVOLUTION_API_KEY=your-api-key
EVOLUTION_API_WEBHOOK_SECRET=your-webhook-secret
Quick Example¶
Send a Text Message¶
use Lynkbyte\EvolutionApi\Facades\EvolutionApi;
// Send a simple text message
$response = EvolutionApi::message()->sendText('my-instance', [
'number' => '5511999999999',
'text' => 'Hello from Laravel!',
]);
// Check if it was successful
if ($response->successful()) {
$messageId = $response->json('key.id');
}
Send a Media Message¶
// Send an image with caption
$response = EvolutionApi::message()->sendMedia('my-instance', [
'number' => '5511999999999',
'mediatype' => 'image',
'media' => 'https://example.com/image.jpg',
'caption' => 'Check out this image!',
]);
Handle Webhooks¶
use Lynkbyte\EvolutionApi\Webhooks\AbstractWebhookHandler;
use Lynkbyte\EvolutionApi\DTOs\WebhookPayloadDto;
class MessageReceivedHandler extends AbstractWebhookHandler
{
public function handle(WebhookPayloadDto $payload): void
{
$message = $payload->data['message'] ?? [];
// Process the incoming message
logger()->info('Message received', [
'from' => $payload->sender,
'text' => $message['conversation'] ?? null,
]);
}
}
Requirements¶
| Requirement | Version |
|---|---|
| PHP | 8.2+ |
| Laravel | 11.x / 12.x |
| Evolution API | 2.x |
Architecture Overview¶
graph TB
subgraph Laravel Application
A[Your Code] --> B[EvolutionApi Facade]
B --> C[EvolutionService]
C --> D[Resource Classes]
D --> E[EvolutionClient]
end
subgraph HTTP Layer
E --> F[Rate Limiter]
F --> G[HTTP Client]
end
subgraph Evolution API
G <--> H[Evolution API Server]
H <--> I[WhatsApp]
end
subgraph Webhooks
H --> J[Webhook Controller]
J --> K[WebhookProcessor]
K --> L[Event Handlers]
end
Support¶
-
GitHub
Report issues, request features, or contribute to the project.
-
Packagist
View package details and version history.
License¶
Laravel Evolution API is open-sourced software licensed under the MIT license.
Made with :heart: by Lynkbyte