Download the PHP package x-laravel/embedding-sqlsrv-driver without Composer
On this page you can find all versions of the php package x-laravel/embedding-sqlsrv-driver. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package embedding-sqlsrv-driver
x-laravel/embedding — SQL Server Driver
SQL Server 2025 / Azure SQL native vector driver for x-laravel/embedding.
How It Works
- Implements
SimilarityDriver— registers as thesqlsrvdriver, similarity search runs entirely in SQL Server usingVECTOR_DISTANCE('cosine', ...) - Implements
VectorStore— writes embeddings viaMERGE INTOwithCAST(? AS VECTOR(n)), reads via aCAST(vector AS NVARCHAR(MAX))global scope - Translates payload
filter:constraints to type-strictOPENJSONSQL against theembeddablestable
Requirements
- PHP ^8.3 +
ext-sqlsrv+ext-pdo_sqlsrv+ Microsoft ODBC Driver 18 - Laravel ^12.0 | ^13.0
x-laravel/embedding ^1.0- SQL Server 2025 or Azure SQL Database (native
VECTORtype required)
Installation
The SqlServerEmbeddingServiceProvider is auto-discovered and registers the sqlsrv 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 SQL Server-native migrations that replace the default ones from x-laravel/embedding: embeddings with a VECTOR(n) 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: The native
VECTORandJSONtypes andVECTOR_DISTANCErequire SQL Server 2025 or Azure SQL Database. They are not available in SQL Server 2019/2022.
3. Model
Follow the standard x-laravel/embedding setup. No SQL Server-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 with OPENJSON — every condition checks the JSON value type, and strings compare with a binary collation, so comparisons are type-strict (34 never matches "34") and case-sensitive:
Note:
pdo_sqlsrvreturns integer columns to PHP as strings. Add anintegercast to numeric payload fields on your models — otherwise a queued payload sync writes"34"instead of34after the DB round-trip, and type-strict filters stop matching.
Testing
License
This package is open-sourced software licensed under the MIT license.