Download the PHP package x-laravel/embedding-mysql-driver without Composer
On this page you can find all versions of the php package x-laravel/embedding-mysql-driver. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package embedding-mysql-driver
x-laravel/embedding — MySQL 9 Driver
MySQL HeatWave native vector driver for x-laravel/embedding.
How It Works
- Implements
SimilarityDriver— registers as themysqldriver, similarity search runs entirely in MySQL usingVEC_DISTANCE_COSINE - Implements
VectorStore— writes embeddings viaINSERT ... ON DUPLICATE KEY UPDATEwithSTRING_TO_VECTOR(), reads via aVECTOR_TO_STRINGglobal scope - Translates payload
filter:constraints to type-strictJSON_EXTRACT/JSON_TYPESQL against theembeddablestable
Requirements
- PHP ^8.3
- Laravel ^12.0 | ^13.0
x-laravel/embedding ^1.0- MySQL HeatWave —
VEC_DISTANCE_COSINEis not available in MySQL Community Edition; this driver requires MySQL HeatWave
Installation
The MysqlEmbeddingServiceProvider is auto-discovered and registers the mysql driver automatically.
Setup
1. Configure x-laravel/embedding
Publish the config if you haven't already:
Set the similarity driver and database connection in config/embedding.php:
2. Create the tables
This driver ships its own MySQL-native migrations that replace the default ones from x-laravel/embedding: embeddings with a VECTOR(1536) column and embeddables with a native JSON payload column.
Publish and run the migrations (migrations are not loaded automatically — publish the driver migrations, not the core ones):
The published files are plain migrations in database/migrations/ — customise the DDL there if needed before running migrate.
Note:
VEC_DISTANCE_COSINEis only available on MySQL HeatWave, not MySQL Community Edition. For production, add aVECTOR INDEXon thevectorcolumn after publishing the migration.
3. Model
Follow the standard x-laravel/embedding setup. No MySQL-specific changes are needed on your models.
Usage
The driver is transparent — use the standard x-laravel/embedding API:
All methods set a similarity_score float attribute on each returned model.
Payload filtering
Models using #[EmbedPayload] can filter similarity searches at the database level. The driver translates filter: to a whereExists subquery against embeddables: every condition checks the value's JSON_TYPE and compares it with CAST(? AS JSON), so comparisons are type-strict (34 never matches "34", true never matches 1) and strings compare case-sensitively:
Note: MySQL returns
TINYINT(1)columns as integers. Add abooleancast to boolean payload fields on your models — otherwise the payload stores1instead oftrue, andfilter: ['active' => true]stops matching.
Testing
Tests require a MySQL HeatWave instance. The docker-compose.yml uses mysql:9.1.0 for CI convenience but VEC_DISTANCE_COSINE tests will fail against Community Edition — run them against a real HeatWave instance.
License
This package is open-sourced software licensed under the MIT license.