x-laravel/embedding-mariadb-driver
Composer 安装命令:
composer require x-laravel/embedding-mariadb-driver
包简介
MariaDB 11.7 native vector similarity driver for x-laravel/embedding.
关键字:
README 文档
README
MariaDB 11.7 native vector driver for x-laravel/embedding.
How It Works
- Implements
SimilarityDriver— registers as themariadbdriver, similarity search runs entirely in MariaDB usingVEC_Distance_Cosine - Implements
VectorStore— writes embeddings viaINSERT ... ON DUPLICATE KEY UPDATEwithVec_FromText(), reads via aVEC_ToTextglobal scope
Requirements
- PHP ^8.3
- Laravel ^12.0 | ^13.0
x-laravel/embedding ^1.0- MariaDB 11.7+
Installation
composer require x-laravel/embedding-mariadb-driver
The MariadbEmbeddingServiceProvider is auto-discovered and registers the mariadb driver automatically.
Setup
1. Configure x-laravel/embedding
Publish the config if you haven't already:
php artisan vendor:publish --tag=embedding-config
Set the similarity driver and database connection in config/embedding.php:
'database' => [ 'connection' => env('EMBEDDINGS_DATABASE_CONNECTION', env('DB_CONNECTION', 'mariadb')), 'table' => env('EMBEDDINGS_DB_TABLE', 'embeddings'), ], 'similarity' => [ 'driver' => env('EMBEDDING_SIMILARITY_DRIVER', 'auto'), ],
2. Create the embeddings table
This driver ships its own MariaDB-native migration that replaces the default one from x-laravel/embedding. It creates a BLOB column for vector storage.
Run the migration:
php artisan migrate
If you need to customise the DDL, publish the migration first:
php artisan vendor:publish --tag=embedding-mariadb-migrations php artisan migrate
Note:
VEC_Distance_Cosinerequires MariaDB 11.7+. For production, add aVECTOR INDEXon thevectorcolumn after publishing the migration.
3. Model
Follow the standard x-laravel/embedding setup. No MariaDB-specific changes are needed on your models.
use XLaravel\Embedding\Attributes\EmbedOn; use XLaravel\Embedding\Concerns\Embeddable; use XLaravel\Embedding\Contracts\HasEmbeddings; #[EmbedOn(['title', 'body'])] class Post extends Model implements HasEmbeddings { use Embeddable; public function toEmbeddingText(): string { return $this->title.' '.$this->body; } }
Usage
The driver is transparent — use the standard x-laravel/embedding API:
Post::similarToText('web framework', limit: 10); Post::similarTo($vector, limit: 10, threshold: 0.8); Post::rankByRelevance($posts, 'web framework'); $post->mostSimilar(limit: 5); $post->similarityTo($otherPost);
All methods set a similarity_score float attribute on each returned model.
Testing
# Build first (once per PHP version) DOCKER_BUILDKIT=0 docker compose --profile php83 build # Run tests docker compose --profile php83 up docker compose --profile php84 up docker compose --profile php85 up
License
This package is open-sourced software licensed under the MIT license.
x-laravel/embedding-mariadb-driver 适用场景与选型建议
x-laravel/embedding-mariadb-driver 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 1 次下载、GitHub Stars 达 0, 最近一次更新时间为 2026 年 05 月 09 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「laravel」 「mariadb」 「vector」 「ai」 「embedding」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 x-laravel/embedding-mariadb-driver 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 x-laravel/embedding-mariadb-driver 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 x-laravel/embedding-mariadb-driver 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Generic, object-oriented Vector, Map, and Set collections with immutable and mutable variants
Powerful PHP database abstraction layer (DBAL) with many features for database schema introspection and management.
Immutable data structures based on php/ds.
Simple PHP client for Qdrant vector database. Easy-to-use library for storing, searching, and managing vector embeddings in AI and machine learning applications.
The lightweight PHP database framework to accelerate development
A modern Laravel package for SVG conversion with multiple provider support (Resvg, Inkscape, rsvg-convert). Convert SVG to PNG, PDF, EPS, and more.
统计信息
- 总下载量: 1
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 30
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-05-09