Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Ai Maria Db Store Laravel Package

symfony/ai-maria-db-store

MariaDB vector store integration for Symfony AI Store. Requires MariaDB 11.7+ for VECTOR columns, vector indexing, and distance search. Useful for building RAG and similarity search apps backed by MariaDB.

View on GitHub
Deep Wiki
Context7

Technical Evaluation

Architecture Fit

  • Vector Store Integration: The package provides a Symfony AI-compatible vector store using MariaDB’s native vector support (v11.7+), enabling semantic search, RAG pipelines, and hybrid SQL/vector queries. This fits architectures requiring cost-effective, embedded vector search within existing relational workflows, but may not suit high-throughput or GPU-accelerated use cases.
  • Symfony-Centric Design: Tightly coupled with Symfony’s AI stack, which could introduce integration friction in Laravel-centric projects unless abstracted via bridges or facades. The package’s adherence to AiStoreInterface ensures consistency with Symfony’s AI components but limits flexibility for non-Symfony ecosystems.
  • Schema and Query Flexibility: Supports dynamic vector dimensions and SQL filtering, but requires manual schema management (e.g., VECTOR columns, indexes). This contrasts with dedicated vector databases that abstract schema complexity, potentially increasing operational overhead for schema evolution.

Integration Feasibility

  • Prerequisites:
    • MariaDB 11.7+: Mandatory for vector support; upgrades may disrupt existing deployments.
    • Symfony AI 0.8+: The package is Symfony-specific; Laravel integration requires Symfony bridge components (e.g., symfony/dependency-injection) or custom wrappers.
    • PHP 8.2+: Aligns with Laravel’s current LTS but may require dependency updates.
  • Compatibility:
    • Laravel Integration: Possible via Symfony bridges or raw PDO, but introduces complexity:
      • Service Container: Laravel’s DI system must resolve Symfony’s AiStoreInterface, potentially requiring custom bootstrapping.
      • Configuration: Symfony’s YAML config must be mapped to Laravel’s config/ai.php, adding maintenance overhead.
    • ORM Conflicts: Eloquent’s query builder may interfere with raw SQL vector operations; recommend isolation via repositories or raw PDO.
  • Technical Debt: Minimal initial debt, but long-term risks include tight coupling to Symfony’s AI stack and MariaDB’s evolving vector features.

Technical Risk

  • Performance and Scalability:
    • CPU-Bound Operations: MariaDB’s vector search lacks GPU acceleration, risking high latency for large datasets (>1M vectors) or high QPS (>1K).
    • Scalability Limits: Horizontal scaling requires manual sharding or read replicas; no native distributed support.
    • Distance Metrics: Limited to cosine/Euclidean/L2; custom metrics require workarounds.
  • Dependency Risk:
    • Symfony AI Maturity: New package (2026) with 0 dependents; risk of breaking changes as Symfony AI evolves.
    • MariaDB Vector Support: Early-stage features may have bugs or undocumented limitations.
  • Laravel-Specific Risks:
    • Configuration Overhead: Laravel’s lack of native Symfony DI may require custom service providers or facades, increasing complexity.
    • Testing Challenges: Vector operations may need mocked PDO connections, complicating unit/integration tests.
    • Legacy Queries: Existing SQL queries may conflict with vector schema changes (e.g., ALTER TABLE).

Key Questions

  1. Use Case Validation:
    • Is the primary goal cost efficiency (MariaDB) or performance (dedicated vector DB)? Benchmark against alternatives (e.g., pgvector, Milvus).
    • Will the dataset exceed 100K vectors? If yes, evaluate sharding/caching strategies.
  2. Stack Constraints:
    • Can the team adopt MariaDB 11.7+ and Symfony’s abstractions, or are there hard Laravel dependencies?
    • Is there a budget for managed vector services (e.g., Pinecone, Weaviate)?
  3. Operational Impact:
    • How will vector index maintenance (e.g., ALTER TABLE) fit into deployments?
    • Are there compliance requirements favoring MariaDB (e.g., data residency)?
  4. Migration Path:
    • Does the current system use legacy vector stores (e.g., Elasticsearch)? If so, how will data be migrated?
    • Are there legacy queries that assume non-vector schemas? How will they coexist?
  5. Long-Term Flexibility:
    • Is the team open to abstracting the store interface (e.g., VectorStoreInterface) to allow future swaps (e.g., to pgvector)?
    • What’s the exit strategy if MariaDB’s vector support proves insufficient?

Integration Approach

Stack Fit

  • Laravel Compatibility:
    • Symfony Bridge: Use symfony/dependency-injection and symfony/console-bridge via Composer, then bind the MariaDB store to Laravel’s container:
      // app/Providers/AppServiceProvider.php
      public function register()
      {
          $this->app->singleton(\Symfony\Component\AI\Store\AiStoreInterface::class, function ($app) {
              return new \Symfony\AI\MariaDbStore\MariaDbStore(
                  $app['db']->connection()->getPdo(),
                  config('ai.maria_db_store')
              );
          });
      }
      
    • Configuration: Map Symfony’s config to Laravel’s config/ai.php:
      'maria_db_store' => [
          'dsn' => env('DATABASE_MARIADB_URL'),
          'table' => 'ai_embeddings',
          'vector_column' => 'embedding',
          'distance' => 'cosine',
          'dimensions' => 1536,
      ],
      
    • Alternative (Lightweight): Use the package’s core classes directly with raw PDO:
      use Symfony\AI\MariaDbStore\MariaDbStore;
      
      $store = new MariaDbStore(
          DB::connection('mariadb')->getPdo(),
          config('ai.maria_db_store')
      );
      
  • Key Considerations:
    • Avoid Eloquent: Use raw PDO or a custom repository layer to prevent conflicts with Laravel’s query builder.
    • Environment-Specific Config: Ensure DATABASE_MARIADB_URL is distinct from the primary Laravel DB.

Migration Path

  1. Phase 1: Infrastructure Setup (1–2 weeks)

    • Upgrade MariaDB: Migrate to v11.7+ and enable vector extensions.
    • Schema Design: Create a table for vectors with VECTOR columns and indexes:
      CREATE TABLE ai_embeddings (
          id INT AUTO_INCREMENT PRIMARY KEY,
          embedding VECTOR(1536),
          metadata JSON,
          created_at TIMESTAMP
      );
      CREATE INDEX idx_embedding ON ai_embeddings ((embedding));
      
    • Dependency Setup: Install the package and Symfony bridges:
      composer require symfony/ai-maria-db-store symfony/dependency-injection symfony/console-bridge
      
  2. Phase 2: Data Migration (2–4 weeks)

    • Backfill Vectors: Script to import existing embeddings (e.g., from CSV, FAISS, or Elasticsearch):
      $store->insertMany([
          ['embedding' => $vector1, 'metadata' => ['id' => 1]],
          ['embedding' => $vector2, 'metadata' => ['id' => 2]],
      ]);
      
    • Hybrid Queries: Test combining vector search with SQL filters:
      $results = $store->findNearest($query, 10, [
          'metadata->$.category' => 'tech',
      ]);
      
  3. Phase 3: Application Integration (3–6 weeks)

    • Replace Legacy Vector Operations: Update services to use the MariaDB store:
      // Before: Elasticsearch
      $results = $elasticsearch->search($query);
      
      // After: MariaDB
      $results = $store->findNearest($query, 5);
      
    • Distance Metrics: Standardize on supported metrics (e.g., cosine).
    • Error Handling: Add retries for transient MariaDB errors (e.g., connection timeouts).
  4. Phase 4: Performance Optimization (Ongoing)

    • Index Tuning: Adjust VECTOR indexes for query patterns (e.g., IVF for large datasets).
    • Caching: Cache frequent queries in Redis or Laravel’s cache:
      $cacheKey = "vector_query_{$queryHash}";
      return cache()->remember($cacheKey, now()->addMinutes(5), function () use ($store, $query) {
          return $store->findNearest($query, 10);
      });
      
    • Monitoring: Track vector operation latency and MariaDB resource usage (e.g., SHOW PROCESSLIST).

Compatibility

  • Laravel Ecosystem:
    • Service Container: Works with Laravel’s DI but requires explicit bindings for Symfony interfaces.
    • Artisan Commands: Symfony’s console components can
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
directorytree/privacy-filter-classifier
directorytree/privacy-filter
datacore/hub-sdk
develia/commons
cuci/prototurk-sdk
cuci/prototurk-sdk-symfony
develia/geo-bundle
dreamzy/livewire-charts
touchestate-sdk/php-sdk
22h/doctrine-garbage-collection-bundle
agtp/agtp-php
agtp/mod-php
splash/sonata-admin
splash/metadata
splash/openapi
splash/scopes
splash/toolkit
testo/output-teamcity
testo/bridge-symfony
spatie/flare-daemon-runtime