Download the PHP package illuma-law/laravel-vector-schema without Composer

On this page you can find all versions of the php package illuma-law/laravel-vector-schema. 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-vector-schema

Laravel Vector Schema

Tests Packagist License Latest Stable Version

Portable vector columns and search macros for Laravel Eloquent.

When building AI applications with RAG (Retrieval-Augmented Generation), you must store and query high-dimensional vector embeddings. However, PostgreSQL (pgvector), SQLite (sqlite-vec), SingleStore, and MySQL all use different syntax for vector data types, index creation, and cosine distance calculations.

This package provides Laravel Blueprint schema macros and Eloquent Builder macros to seamlessly abstract away these database differences, giving you a unified API for vector search across all supported databases.

Features

Database Support Matrix

Database Support Level Requirements Distance Function
PostgreSQL Native pgvector extension <=> (Cosine)
MySQL (9.0+) Native HeatWave or Enterprise Edition VECTOR_DISTANCE
MariaDB (11.7+) Native None VEC_DISTANCE_COSINE
SQL Server Native Azure SQL (Preview) VECTOR_DISTANCE
SingleStore Native None DOT_PRODUCT
SQLite Native sqlite-vec extension vec_distance_cosine

Note: MySQL Community Edition (GPL) currently restricts the VECTOR_DISTANCE function to HeatWave/Enterprise users. SQLite requires loading the sqlite-vec extension.

Installation

You can install the package via composer:

The Service Provider will automatically register the Blueprint and Builder macros.

Usage & Integration

Schema Migrations

Use the vectorColumn macro to define portable vector columns. On PostgreSQL, MySQL, MariaDB, SQL Server, and SingleStore, this creates a native vector column. On SQLite, it safely falls back to a BLOB column compatible with sqlite-vec.

Use hnswIndex for high-performance approximate nearest neighbor (ANN) similarity search. This generates a native HNSW index on PostgreSQL and is gracefully ignored on other drivers.

Eloquent Casts

Add the VectorArray cast to your Eloquent model. This handles the serialization and deserialization of plain PHP arrays into the specific formats required by your active database driver.

Now you can interact with the vector just like a normal array:

Vector Math Utilities (VectorProcessor)

When dealing with high-dimensional vectors, you often need to perform common mathematical operations such as normalizing input data or averaging several vectors (e.g., to create a centroid for a cluster or a search query).

The package includes a domain-agnostic VectorProcessor class for these tasks.

normalizeVector

Ensures an input vector is a flat list of floats, filters out NaN or INF values, and validates the expected dimensionality. Returns an empty array if the input is invalid.

averageVectors

Computes the mathematical average (centroid) of a collection of vectors. This is useful for combining multiple embeddings into a single query vector.

Vector Querying (Semantic Search)

The package provides several macros attached to the Laravel Query Builder.

whereHybridVectorSimilarTo

Filter results to only include those that meet a minimum cosine similarity threshold. You can also ask the macro to automatically order the results by similarity (closest first).

selectHybridVectorDistance

Select the raw cosine distance between a stored vector and your query vector into a dynamically named alias. Note that distance is the inverse of similarity (0.0 is an exact match).

whereHybridVectorDistanceLessThan

If you prefer thinking in distances rather than similarities, directly filter by the raw distance.

orderByHybridVectorDistance

If you only need to order results by semantic proximity without filtering or selecting the specific distance value:

Testing

The package includes a comprehensive test suite using Pest.

License

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


All versions of laravel-vector-schema with dependencies

PHP Build Version
Package Version
Requires php Version ^8.3
spatie/laravel-package-tools Version ^1.16
illuminate/contracts Version ^11.0||^12.0||^13.0
illuminate/database Version ^11.0||^12.0||^13.0
illuminate/support Version ^11.0||^12.0||^13.0
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 illuma-law/laravel-vector-schema contains the following files

Loading the files please wait ...