symfony/ai-doctrine-message-store
Doctrine DBAL message store integration for Symfony AI Chat. Persist and retrieve chat messages in a relational database using Doctrine DBAL, enabling durable conversation history and easy storage configuration within Symfony applications.
doctrine/dbal support reduces friction.doctrine/dbal (v3.x+).Messenger for compatibility.laravel-ai) or build a message store facade.Schema builder or Doctrine tools.Illuminate\Bus) are not PSR-15-native, necessitating custom middleware or wrapper classes.symfony/ai and this store to validate PSR-15 integration.spatie/laravel-redis-message-store).DatabaseManager if PSR-15 is prohibitive.spatie/laravel-ai) that reduce Symfony dependency?| Component | Laravel Equivalent/Adapter Needed | Notes |
|---|---|---|
| Doctrine DBAL | doctrine/dbal (v3.x) |
Native support; no changes required. |
| PSR-15 Message Store | Custom wrapper or Symfony’s Messenger |
Laravel lacks PSR-15; bridge required. |
| Symfony AI Chat | Replace with laravel-ai or custom LLM service |
Avoid Symfony dependency bloat. |
| Schema Migrations | Laravel Schema builder or Doctrine Migrations |
Prefer Laravel’s for consistency. |
laravel-ai (if available) or a custom PSR-15 adapter.spatie/laravel-redis-message-store).Phase 1: Proof of Concept (1–2 weeks)
composer require doctrine/dbal symfony/ai-doctrine-message-store
MessageStore facade wrapping the Symfony store).Phase 2: Schema Integration (1 week)
php artisan make:migration create_ai_messages_table --table=ai_messages
Phase 3: AI Integration (2–3 weeks)
// config/ai.php
'message_store' => [
'primary' => \App\Services\HybridMessageStore::class,
'drivers' => [
'dbal' => \Symfony\AI\DoctrineMessageStore\DoctrineDBALMessageStore::class,
'redis' => \Spatie\RedisMessageStore::class,
],
];
Phase 4: Monitoring (Ongoing)
DB::listen.schema:update checks).Laravel Debugbar).LaravelMessageStore implementing MessageStoreInterface).Messenger (if already in stack) to consume PSR-15 messages.DatabaseManager directly for simplicity.laravel-ai packages (if available).AIService::storeMessage()).doctrine/dbal is installed and configured in config/database.php.// database/migrations/xxxx_create_ai_messages_table.php
Schema::create('ai_messages', function (Blueprint $table) {
$table->id();
$table->string('conversation_id');
$table->text('message');
$table->json('metadata')->nullable();
$table->timestamps();
});
// app/Services/LaravelMessageStore.php
namespace App\Services;
use Symfony\Component\Messenger\Message\SentMessageInterface;
use Symfony\Component\Messenger\Transport\Serialization\SerializerInterface;
use Doctrine\DBAL\Connection;
class LaravelMessageStore implements \Symfony\Component\Messenger\MessageStoreInterface
{
public function __construct(private Connection $connection) {}
public function ack(SentMessageInterface $message): void
{
// Implement DBAL-based ack logic
}
public function reject(SentMessageInterface $message, \Throwable $reason): void
{
// Implement rejection logic
How can I help you explore Laravel packages today?