Download the PHP package avadim/manticore-query-builder-laravel without Composer

On this page you can find all versions of the php package avadim/manticore-query-builder-laravel. 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 manticore-query-builder-laravel

English | Русский

GitHub Release Packagist Downloads GitHub License Static Badge Static Badge

ManticoreSearch Query Builder for Laravel

The easiest way to use the ManticoreSearch Query Builder in your Laravel or Lumen applications. This package allows you to build ManticoreSearch queries using a Laravel-like syntax.

The query builder is a separate package and is where the syntax of a query lives — match(), where(), insert(), the schema of a table. This one adds what only means something inside the framework: the service provider and the config file, named connections, and answers of the shape Laravel expects.

Contents

Related packages

Requirements

A few things need more than the bare server: KNN vector search needs the KNN library, columnar storage the columnar one, rename() needs Manticore Buddy. What needs what is listed in the requirements of the query builder.

Installation

Laravel

The service provider of the package registers itself.

Publish the configuration file:

Lumen

Lumen discovers nothing on its own, so the service provider, the configuration and the alias are registered by hand in bootstrap/app.php:

Copy the configuration file into your application by hand as well.

Configuration

After the configuration file is published, a connection is set up in the .env file of your application (with appropriate values):

All available environment variables

Name Default value Description
MANTICORE_CONNECTION default Name of default connection
MANTICORE_HOST localhost Address of host with Manticore server
MANTICORE_PORT 9306 Port of the SQL interface of the server
MANTICORE_USER Username
MANTICORE_PASS Password
MANTICORE_TIMEOUT 5 Timeout between requests
MANTICORE_PREFIX Prefix that replaces the placeholder ? in front of a table name
MANTICORE_FORCE_PREFIX false Prefix every table name, not only the ones written with ?

A prefix keeps the tables of an application apart from the rest of a shared server: table('?products') reads the table myapp_products when the prefix is myapp_. With MANTICORE_FORCE_PREFIX=true the ? can be left out — every name is prefixed.

More connections are added to the connections array of config/manticore.php, each with the same set of keys; defaultConnection names the one used when no name is given.

Quick start

Everything between table() and the read — full-text match(), where(), aggregates, faceted search, JOIN, KNN vector search, the schema of a table — belongs to the query builder and is described in its documentation. The sections below cover what this package does differently.

The alias, the facade and the container

The \ManticoreDb alias of the examples is registered by the package itself. It is the shortest way in, but not the only one — the same connection is reachable through the facade and through the container:

All three answer alike: they share the connections, and a query built through any of them returns the collections described below. Manager answers the methods of a connection through __call(), which the @method annotations of the class describe, so an IDE completes them.

What the reads return

The standalone query builder answers with plain arrays — a collection there would mean an extra dependency in a framework-agnostic library. Inside Laravel the framework is a given, so this package answers the way Laravel does:

A Row reads both ways, so the code written against the array answer of the standalone builder keeps working:

Writes are untouched and keep the answers of the builder: insert() returns bool, update() and delete() the number of affected rows, insertGetId() the id.

When a query fails

A rejected read throws avadim\Manticore\QueryBuilder\QueryErrorException — a query with a mistake in it is a bug, not an empty result set, and an exception says so where it happened:

Writes keep answering with a value instead: false from insert(), zero affected rows from update() and delete(). The reason of the last statement, successful or not, is kept in its result set:

A full-text query typed by a visitor is the usual source of a rejected read, so it is worth passing through \ManticoreDb::escapeMatch($text) before it reaches match().

Pagination

Both accept the same arguments as in Laravel: paginate($perPage, $columns, $pageName, $page).

Transactions

Manticore serves BEGIN / COMMIT / ROLLBACK on real-time tables, so a transaction is written the way it is elsewhere in Laravel. Transactions live in the query builder itself, so the static call works too:

The callback receives the connection, and whatever it returns becomes the result of transaction(). An exception rolls the transaction back and is rethrown; a second argument sets how many times to try. Manticore has no savepoints, so a nested transaction() only counts a level deeper — the outermost commit is the one that writes.

Any SQL statement can be run directly:

Migrations

A table of Manticore is created in a Laravel migration like any other:

Manticore has no transactional DDL, so a migration that fails halfway leaves behind whatever it had already created — write down() so that it can be run over a half-built table.

A table already in use is changed the same way:

Three things this differs in from a migration of a SQL database:

Long-running workers

A connection remembers the schema of every table it has described, which saves a DESCRIBE before each query and is what casts the values of a row into PHP types. The cache lives as long as the connection does — the length of a request under php-fpm, but much longer under Octane, a queue worker or a scheduled command.

So a table altered from somewhere else needs the cache dropped:

The builder keeps its own cache in step: create(), alter(), addColumn(), dropColumn(), truncate(), rename() and drop() drop the schema of the table they touched. What it cannot know about is a statement of yours — a migration run by another process, an ALTER sent through statement(), a table rebuilt by an indexer.

Logging

You can use logger instance for logging in this package.

Any PSR-3 logger will do, \Log::getLogger() is the one of Laravel. Service queries the builder sends on its own, DESCRIBE among them, are not logged.

Documentation

The syntax of a query, the schema of a table and everything else the builder does is described in the documentation of avadim/manticore-query-builder-php. Manticore Search itself is documented at https://manual.manticoresearch.com/

Testing

Some tests need a running ManticoreSearch server. By default they use 127.0.0.1:9306, this can be changed with the MANTICORE_TEST_HOST and MANTICORE_TEST_PORT environment variables in phpunit.xml.dist. If the server is unreachable those tests are skipped, the rest of the suite still runs. Tables created by the tests are named phpunit_* and are dropped afterwards.


All versions of manticore-query-builder-laravel with dependencies

PHP Build Version
Package Version
Requires php Version ^7.4|^8.1
ext-json Version *
psr/log Version >=1.1
avadim/manticore-query-builder-php Version ^2.1
illuminate/support Version ^6.0|^7.0|^8.0|^9.0|^10.0|^11.0|^12.0|^13.0
illuminate/contracts Version ^6.0|^7.0|^8.0|^9.0|^10.0|^11.0|^12.0|^13.0
illuminate/pagination Version ^6.0|^7.0|^8.0|^9.0|^10.0|^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 avadim/manticore-query-builder-laravel contains the following files

Loading the files please wait ...