Download the PHP package devilsberg/laravel-mariadb-vector without Composer

On this page you can find all versions of the php package devilsberg/laravel-mariadb-vector. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package laravel-mariadb-vector

Laravel MariaDB Vector

Latest Version on Packagist Tests License Ko-fi

MariaDB 11.7+ native vector storage and search for Laravel.

This package brings vector column support, binary-safe casting, and similarity search macros to Eloquent — powered by MariaDB's native VECTOR type and VEC_DISTANCE_* functions. Think of it as the MariaDB equivalent of pgvector for Laravel.

Requirements

Installation

Publish the config file:

Quick Start

1. Create a migration

2. Set up your model

3. Store a vector

4. Search by similarity

Vector Indexes

Without a vector index every similarity search performs a full table scan — fine for thousands of rows, slow at scale. MariaDB 11.7 supports VECTOR INDEX for approximate nearest neighbor (ANN) lookups, exposed via the standard vectorIndex() Blueprint method that Laravel 12 provides.

Adding an index in a migration

Custom index name

By default the index name follows Laravel's standard index naming — {table}_{column}_vectorindex:

Adding an index to an existing table

Note: MariaDB requires the vector column to be NOT NULL to add a vector index. Attempting to index a nullable vector column will raise a database error.

Note: MariaDB 11.7 supports only one VECTOR INDEX per table. Attempting to add a second one will raise a database error.

Bring Your Own Embeddings

This package handles storage and search only. You generate embeddings however you want — Ollama, Mistral, Cohere, a local Python model, or anything that produces a float array.

VectorCast

VectorCast handles conversion between MariaDB's binary VECTOR format and PHP float arrays.

The column supports ->nullable() in migrations:

Query Builder Macros

All macros are registered on Illuminate\Database\Eloquent\Builder.

whereVectorSimilarTo

Filter results by vector distance threshold.

Generates: WHERE VEC_DISTANCE_COSINE(\embedding`, VEC_FromText(?)) < ?`

orderByVectorDistance

Sort results by vector distance (nearest first).

Generates: ORDER BY VEC_DISTANCE_COSINE(\embedding`, VEC_FromText(?)) asc`

selectVectorDistance

Include the distance score in query results.

Generates: VEC_DISTANCE_COSINE(\embedding`, VEC_FromText(?)) as `score``

nearestNeighbors

The recommended macro for most use cases. Computes the distance once per row as a normalized score column and orders results by highest score first. More efficient than chaining the three individual macros.

Generates:

The score is a normalized similarity value — higher means more similar:

Combining macros

For advanced queries where you need threshold filtering alongside ordering, use the individual macros:

Configuration

Published to config/vector.php:

Key Default Description
default_dimensions 768 Default dimensions for vector columns
distance_metric COSINE Distance function: COSINE or EUCLIDEAN

Note: DOT product distance is not supported by MariaDB. Configuring it will throw an InvalidArgumentException.

Testing

Run the unit tests:

Run the integration tests (requires a live MariaDB instance):

Configure MariaDB credentials in phpunit.xml:

Run the full suite:

Support

If this package saves you time, consider buying me a coffee.

ko-fi

License

The MIT License (MIT). Please see License File for more information.


All versions of laravel-mariadb-vector with dependencies

PHP Build Version
Package Version
Requires php Version ^8.4
laravel/framework Version ^12.0 || ^13.0
spatie/laravel-package-tools Version ^1.16
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package devilsberg/laravel-mariadb-vector contains the following files

Loading the files please wait ...