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

Singlestoredb Laravel Laravel Package

singlestoredb/singlestoredb-laravel

Official SingleStoreDB driver for Laravel. Wraps Laravel’s MySQL support to work smoothly with SingleStore, adding Eloquent/migration features (columnstore/rowstore, shard/sort keys, sparse), JSON column support, and compatibility fixes.

View on GitHub
Deep Wiki
Context7

Technical Evaluation

Architecture Fit

  • Strengths:

    • SingleStoreDB Optimization: The driver extends Laravel’s MySQL driver to expose SingleStoreDB-specific features (e.g., Universal Storage, shard/sort keys, sparse columns) via Eloquent and Schema Builder, aligning with SingleStore’s hybrid transactional/analytical workloads.
    • Compatibility: Leverages Laravel’s existing MySQL abstraction, reducing refactoring risk for teams already using Laravel’s ORM/Query Builder.
    • Feature Parity: Supports advanced SingleStoreDB features (e.g., columnstore tables, global temp tables, computed columns) natively, enabling performance-critical use cases like real-time analytics or mixed workloads.
    • Performance: Optimized for SingleStoreDB’s connection model (e.g., persistent connections, SSL tuning), critical for high-throughput applications.
  • Gaps:

    • Limited Query Builder Extensions: No native support for SingleStoreDB-specific SQL functions (e.g., ARRAY_AGG, JSON_TABLE) in the Query Builder, requiring raw SQL or custom macros.
    • ORM Constraints: Eloquent’s ORDER BY in UPDATE/DELETE is unsupported (workaround provided), which may limit complex bulk operations.
    • No ActiveRecord for Advanced Features: Features like shardKey or sortKey require Schema Builder usage; Eloquent models lack direct attribute-level configuration (e.g., @ShardKey).

Integration Feasibility

  • Low Risk for Greenfield Projects: Minimal changes needed beyond swapping the driver in config/database.php and updating migrations to use SingleStore-specific syntax.
  • Moderate Risk for Legacy Systems:
    • Query Compatibility: Existing queries using ORDER BY in UPDATE/DELETE or MySQL-specific functions (e.g., GROUP_CONCAT) may fail without adjustments.
    • Schema Migrations: Tables with MySQL-specific constraints (e.g., ENGINE=InnoDB) or unsupported data types (e.g., ENUM) require refactoring.
    • Third-Party Packages: Packages relying on raw MySQL queries (e.g., reporting tools, caching layers) may need updates.
  • Testing Overhead: Requires validation of:
    • Transaction isolation (SingleStoreDB uses MVCC but differs from MySQL).
    • Connection pooling behavior (persistent connections default to true).
    • JSON/array handling (SingleStoreDB’s JSON type vs. Laravel’s json casting).

Technical Risk

Risk Area Severity Mitigation
Connection Stability High Test persistent connections under load; monitor idle connection limits.
Schema Migration Failures Medium Use singlestore:dump and singlestore:fresh for safe state resets.
Query Performance Medium Profile with EXPLAIN; leverage sortKey/shardKey for analytical workloads.
ORM Limitations Low Use raw SQL or Query Builder macros for unsupported features.
SSL/Network Issues Medium Pre-validate certificate paths for SingleStore Managed Service.

Key Questions for Stakeholders

  1. Workload Profile:
    • Is the primary use case transactional (rowstore), analytical (columnstore), or hybrid? This dictates table type selection.
    • Are there bulk operations (e.g., UPDATE ... ORDER BY) that require workarounds?
  2. Compatibility:
    • Does the application use MySQL-specific features (e.g., stored procedures, triggers) that aren’t supported?
    • Are there third-party Laravel packages that interact with the database layer?
  3. Performance SLAs:
    • What are the latency and throughput requirements for read/write operations?
    • Is connection pooling already managed (e.g., by a proxy like ProxySQL), or will persistent connections suffice?
  4. Operational Constraints:
    • Is the team familiar with SingleStoreDB’s distributed architecture (e.g., sharding, replication)?
    • Are there backup/restore processes that need adaptation for SingleStoreDB?
  5. Future-Proofing:
    • Does the roadmap include new SingleStoreDB features (e.g., Machine Learning, GraphQL) that might require driver updates?
    • Is there a rollback plan to MySQL if issues arise?

Integration Approach

Stack Fit

  • Laravel Version: Tested against Laravel 8+ (PHP 8.1+ recommended for PDO fixes). Compatibility Notes:
    • Laravel 9/10: May require adjustments for new query builder features (e.g., truncate).
    • Laravel 7: Use PDO::ATTR_EMULATE_PREPARES = false to avoid PHP <8.1 bugs.
  • PHP Extensions:
    • Mandatory: pdo_mysql (required by SingleStoreDB driver).
    • Recommended: pdo_pgsql (for cross-database migrations) or redis (for connection pooling).
  • SingleStoreDB Version:
    • Tested against SingleStoreDB 8.0+. Check:
      • Compatibility with SingleStore Managed Service (SSL certificate handling).
      • Support for SingleStoreDB’s latest features (e.g., SEMI_JOIN optimizations).

Migration Path

Phase Tasks Tools/Commands
Pre-Migration 1. Audit queries for MySQL-specific syntax. php artisan db:show
2. Test connection with singlestore:dump (schema-only). php artisan singlestore:dump
3. Update config/database.php to use singlestore driver. Manual config edit
Schema Migration 1. Convert migrations to use SingleStore-specific syntax (e.g., columnstore(), shardKey). Schema Builder methods
2. Handle unsupported features (e.g., ENUMVARCHAR). Manual SQL or custom macros
Data Migration 1. Migrate data using singlestore:fresh --seed (if starting fresh). php artisan migrate:fresh --seed
2. For incremental migration, use DB::connection('mysql')->getSchemaBuilder() → SingleStore. Custom migration script
Application Testing 1. Test Eloquent models, Query Builder, and raw SQL. PHPUnit + Pest
2. Validate transactions, caching (e.g., cache:table driver). php artisan tinker
Go-Live 1. Update DB_CONNECTION in .env. env('DB_CONNECTION', 'singlestore')
2. Monitor connection pooling and query performance. SingleStoreDB Cloud UI / Prometheus

Compatibility

  • Supported:
    • Eloquent ORM (with limitations on ORDER BY in bulk ops).
    • Query Builder (with SingleStore-specific extensions).
    • Migrations (enhanced with SingleStore syntax).
    • Caching (cache:table driver).
    • Queues (failed_jobs table).
  • Unsupported/Workarounds:
    • MySQL-Specific:
      • LOAD DATA INFILE: Use SingleStoreDB’s LOAD DATA or COPY commands.
      • ENGINE=InnoDB: Omit or use rowstore().
    • Laravel-Specific:
      • Schema::defaultStringLength(): SingleStoreDB uses utf8mb4 by default.
      • SoftDeletes: Works, but deleted_at may benefit from a sortKey.
    • Performance:
      • LIMIT/OFFSET with ORDER BY: Use sortKey for pagination.
      • Large transactions: SingleStoreDB supports autocommit; test isolation levels.

Sequencing

  1. Non-Production First:
    • Test in a staging environment with a SingleStoreDB replica of production data.
    • Use feature flags to toggle database connections for gradual rollout.
  2. Phased Rollout:
    • Phase 1: Migrate read-heavy services (e.g., analytics dashboards).
    • Phase 2: Migrate write-heavy services (e.g., user-facing APIs).
    • Phase 3: Migrate background jobs (queues, cron).
  3. Rollback Plan:
    • Maintain a MySQL fallback for critical paths until confidence is high.
    • Use database-specific migrations (e.g., singlestore:fresh for resets).

Operational Impact

Maintenance

  • Driver Updates:
    • Monitor the [
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.
nexmo/api-specification
capell-app/block-library
axium/identity
cetria/laravel-dummy-models
cetria/reflection-helper
agropredict/sso-auth-bundle
evolvestudio/spam-protection
datacore/hub-sdk
develia/commons
cuci/prototurk-sdk
cuci/prototurk-sdk-symfony
develia/geo-bundle
dreamzy/livewire-charts
touchestate-sdk/php-sdk
ecotone/kafka
22h/doctrine-garbage-collection-bundle
agtp/agtp-php
agtp/mod-php
splash/sonata-admin
splash/metadata