Skip to content

Laravel MatrixOneMatrixOne Driver for Laravel

Use MatrixOne as a drop-in Laravel database — Eloquent, Query Builder, Schema Builder, migrations and transactions.

Full-text search, two ways ​

MatrixOne has native FULLTEXT indexes (BM25 or TF-IDF ranking, an ngram parser for Chinese, Japanese and Korean). The package exposes them in two ways.

1. Built in: query builder and Eloquent ​

For models stored in MatrixOne. Create the index in a migration and query it like any Laravel full-text search, with relevance ranking:

php
Schema::create('articles', function (Blueprint $table) {
    $table->id();                       // MatrixOne needs a primary key for FULLTEXT
    $table->string('title');
    $table->text('body');
    $table->fullText(['title', 'body'])->parser('ngram');   // parser optional
});

Article::whereFullText(['title', 'body'], 'vector database')->get();
Article::searchFullText(['title', 'body'], $term)->limit(20)->get();      // filter + order by relevance
Article::select('id')->selectFullTextRelevance(['title', 'body'], $term, as: 'score')->get();

// Boolean queries: +must -exclude "phrases" prefix*
use MatrixOne\Support\FullTextQuery;

Article::searchFullText(['title', 'body'],
    FullTextQuery::make()->must('laravel')->mustNot('legacy')->prefix('match')
)->get();
Article::searchFullText('body', FullTextQuery::anyOf($userInput))->get();   // any word, like a search box

Full-text Search guide →

2. Laravel Scout drivers ​

SCOUT_DRIVER=matrixone searches the model's own MatrixOne table: full-text and LIKE columns, relevance ordering, and semantic or hybrid search on a vector column.

php
#[SearchUsingFullText(['title', 'body'])]
public function toSearchableArray(): array { /* ... */ }

Article::search('vector database')->get();               // full-text, by relevance
Article::search('how to store songs')->semantic()->get(); // cosine similarity
Article::search('songs')->hybrid()->get();                // rank fusion of both

SCOUT_DRIVER=matrixone-index uses a separate MatrixOne database as the search index, like Meilisearch or Algolia. Your models can stay in MySQL, PostgreSQL, CockroachDB or SQLite:

php
// config/scout.php
'matrixone-index' => [
    'connection' => 'matrixone_search',
    'index-settings' => [
        Article::class => [
            'fulltext' => ['title', 'body'],
            'filterable' => ['status', 'author_id' => 'integer'],
            'sortable' => ['published_at' => 'datetime'],
            'fold_accents' => true,   // "tieng viet" matches "Tiếng Việt"
            'prefix' => true,         // "learn" matches "learning"
            'embedding' => 1536,      // enables ->semantic() and ->hybrid()
        ],
    ],
],

Article::search('laravel')->where('status', 'published')->orderBy('published_at', 'desc')->paginate(20);

Scout integration guide →

Laravel Pulse and Telescope ​

Both packages store their data in the database, and both run on MatrixOne. Tests cover recording, aggregation, dashboards and pruning.

Pulse. The package binds a MatrixOne storage automatically when Pulse is installed. Publish its migration instead of Pulse's own, which MatrixOne rejects:

bash
composer require laravel/pulse
php artisan vendor:publish --provider="Laravel\Pulse\PulseServiceProvider" --tag=pulse-config
php artisan vendor:publish --tag=matrixone-pulse-migrations
php artisan migrate

Keep PULSE_STORAGE_DRIVER=database; pulse.storage.database.connection may point to a MatrixOne connection. The dashboard's aggregates, graphs and top lists work.

Telescope. No change needed: install it as usual, with its own migration.

bash
composer require laravel/telescope
php artisan telescope:install
php artisan migrate

The database cache, queue and session drivers work too (CACHE_STORE=database, QUEUE_CONNECTION=database, SESSION_DRIVER=database).

Integrations guide →

Companion packages ​

Companion packages →

Released under the MIT License.