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 leverages MariaDB’s native vector support (v11.7+) to provide a Symfony AI-compatible vector store, enabling semantic search, RAG pipelines, and hybrid SQL/vector queries. This aligns well with architectures prioritizing cost efficiency and database-native vector storage, but may not suit high-throughput or GPU-accelerated use cases.
  • Laravel-Symfony Integration: The package is Symfony-centric, requiring abstraction layers (e.g., bridges, facades) to integrate with Laravel’s ecosystem. This introduces architectural complexity but remains feasible with careful design.
  • Schema Flexibility: Supports dynamic vector dimensions and SQL filtering, but requires manual schema management (e.g., VECTOR columns, indexes). This contrasts with dedicated vector databases, 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

  • Symfony Bridge for Laravel:
    • Use symfony/dependency-injection and symfony/console-bridge via Composer to resolve Symfony’s AiStoreInterface in Laravel’s container.
    • Bind the MariaDB store as a singleton in Laravel’s AppServiceProvider:
      public function register()
      {
          $this->app->singleton(\Symfony\Component\AI\Store\AiStoreInterface::class, function ($app) {
              return new \Symfony\AI\MariaDbStore\MariaDbStore(
                  $app['db']->connection('mariadb')->getPdo(),
                  config('ai.maria_db_store')
              );
          });
      }
      
  • Configuration Mapping:
    • Map Symfony’s YAML 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,
      ],
      
  • Lightweight Alternative:
    • Use the package’s core classes directly with raw PDO to avoid Symfony dependencies:
      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 config/ai.php supports different environments (e.g., staging/production).

Migration Path

  1. Phase 1: Proof of Concept (PoC)
    • Set up a dedicated MariaDB 11.7+ instance for testing.
    • Implement a minimal vector table (e.g., ai_embeddings) with VECTOR column and index.
    • Integrate the store via raw PDO (avoid Symfony bridges initially).
    • Test CRUD operations (insert, query, delete) with synthetic data.
  2. Phase 2: Laravel Integration
    • Abstract Symfony dependencies using facades or custom service providers.
    • Map Symfony’s config to Laravel’s config/ai.php.
    • Benchmark performance against baseline queries (e.g., SELECT * FROM ai_embeddings ORDER BY VECTOR_DISTANCE(...) LIMIT 10).
  3. Phase 3: Hybrid Search Implementation
    • Combine vector queries with SQL filters (e.g., WHERE category = 'tech').
    • Implement caching (e.g., Redis) for frequent queries.
  4. Phase 4: Scaling and Optimization
    • Evaluate sharding or read replicas for datasets >1M vectors.
    • Monitor index maintenance (e.g., ALTER TABLE impact on production).

Compatibility

  • MariaDB Version: Ensure 11.7+ is deployed; test with 11.7.0 and 11.8.x for compatibility.
  • Symfony AI Version: Align with 0.8+ to avoid breaking changes.
  • Laravel Version: Test with Laravel 10.x (PHP 8.2+) and 11.x (PHP 8.3+).
  • Dependency Conflicts: Use composer why symfony/dependency-injection to resolve conflicts; consider alias packages if needed.

Sequencing

  1. Upgrade MariaDB: Migrate to 11.7+ with minimal downtime (use pt-upgrade or mariabackup).
  2. Schema Migration: Create the vector table and index:
    CREATE TABLE ai_embeddings (
        id INT AUTO_INCREMENT PRIMARY KEY,
        embedding VECTOR(1536),
        metadata JSON,
        created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
    ) ENGINE=InnoDB;
    
    CREATE INDEX idx_embedding ON ai_embeddings ((embedding)) USING HNSW;
    
  3. Laravel Integration: Implement the store via raw PDO first, then abstract Symfony dependencies.
  4. Data Migration: Script to migrate existing embeddings (e.g., from Elasticsearch) into the new table.
  5. Application Integration: Update AI services to use the new store (e.g., semantic search, RAG).

Operational Impact

Maintenance

  • Schema Management:

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.
terminal42/code-quality-tools
codifyo/ts-generator-bundle
andydefer/laravel-cluster
testo/fiber
mintobit/jobqueue
a4sex/maintenance-bundle
a4sex/entity-date-update
a4sex/client-identifier
a4sex/base-utilites
a4sex/key-value-storage
a4sex/micro-status
chilldev/dependency-injection-extra
datinglibre/datinglibre-app-api
biberltd/corebundle
bricre/symfony-bundle-test
biberltd/logbundle
dominium/http-adapter-bundle
dominium/google-analytics
a4sex/auto-clean-entity
christhompsontldr/laravel-inky