Download the PHP package nordsoftware/lumen-elasticsearch without Composer

On this page you can find all versions of the php package nordsoftware/lumen-elasticsearch. 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 lumen-elasticsearch

Lumen Elasticsearch

Build Status Coverage Status Code Climate Scrutinizer Code Quality StyleCI Latest Stable Version Total Downloads

Simple wrapper of Elasticsearch-PHP for the Lumen PHP framework.

Version support

Lumen Elasticsearch PHP Library
>= 6.0 5.x >= 7.1 3.8 - 3.x
>= 5.4, <= 6.0 5.x >= 7.1 3.0 - 3.7
5.4.x 5.x >= 5.6 2.x
5.4.x 2.x >= 5.6 1.x
5.2.x 2.x >= 5.6 0.7.x

Requirements

Usage

Installation

Run the following command to install the package through Composer:

Copy the configuration template in config/elasticsearch.php to your application's config directory and modify it to suit your needs.

Add the following line to :

You can now get the service instance using or inject the where needed.

Configuring your indices

You can create and delete indices using the provided console commands. Start by adding the commands to your console kernel:

To create an index you need a configuration file that describes how the index should look. To create an index called my-index, create a file named my-index.php in the config/elasticsearch directory (create the directory if it doesn't exist) with the following contents:

Please refer to the official Elasticsearch documentation for more information on how to define indices.

Now that you have a configuration file for your index, create it by running php artisan elastic:index:create config/elasticsearch/my-index.php.

To delete the index, run php artisan elastic:index:delete my-index.

Indexing your data

To index data into your newly created indices you need to create a new console command that extends Nord\Lumen\Elasticsearch\Console\IndexCommand, then register that command in your console kernel. A sample implementation can look like this:

Now, run php artisan app:index:persons to index the data. You can now create additional commands for your other data types that need to be indexed.

In addition to IndexCommand there is an AbstractMultiIndexCommand that can be used if you need to index the same data into multiple indices. This can be useful if you're migrating Elasticsearch 5.x indices to Elasticsearch 6.x, which doesn't support indices with multiple different document types.

Indexing single items

The console commands are useful when you want to index all items of a particular type, e.g. all persons in your database. However, if you update a single person you probably want to reindex just that person.

Here's an example:

Running queries

Queries against the search index are run by creating a query, then creating a search using the query and finally executing the query using the provided service.

Here's an example:

You can also perform raw queries:

Creating and applying index migrations

Sometimes you need to make a change to an index mapping that requires data to be re-indexed. However, most of the time you don't need to actually index everything into Elasticsearch again, instead it is enough to just copy the data internally from your original index to a new one. This process can be performed seamlessly without downtime.

Requirements

Creating a migration

This will create a directory named versions as well as a timestamped copy of your index definition file.

Applying a migration

If you haven't run migrations before, your index will be replaced by an alias of the same name once the new index has been created. The next time you apply a migration, the alias will simply be updated.

If your documents are very large you may want to decrease the batch size used during re-indexing to prevent Elasticsearch from running out of memory. You can do so by passing --batchSize=X to the elastic:migrations:migrate command. If the option is omitted, the default value of 1000 is used.

Updating dynamic index settings

There is a console command (elastic:index:settings:update) that you can use to update certain dynamic index settings such as the refresh interval or the number of replicas. Simply register it in your console kernel to start using it.

Using index prefixes

This library supports specifying a prefix for index names, similarly to how many frameworks support cache prefixes in order to allow multiple applications to share the same cache. This means you can use a single Elasticsearch cluster for multiple projects (or for example a shared one for the "dev" and "staging" environment).

The prefix used is specified by the configuration file (config/elasticsearch.php). The default behavior is to read the prefix from the ELASTICSEARCH_INDEX_PREFIX environment variable.

If you have an index named content and you specify foo as a prefix, the index will be named foo_content. If you need custom logic you can override getPrefixedIndexName() in ElasticsearchService.

Prefixing is supported for index migrations too, in which case the both the indices and the aliases created are prefixed.

Pagerfanta integration

There is a Pagerfanta adapter included for easy pagination. However, it is optional, so if you intend to use it you must require the pagerfanta/pagerfanta package explicitly.

Contributing

Please read the guidelines.

Running tests

Clone the project and install its dependencies by running:

Run the following command to run the test suite:

License

See LICENSE.


All versions of lumen-elasticsearch with dependencies

PHP Build Version
Package Version
Requires php Version >=7.1
elasticsearch/elasticsearch Version ^5.3
illuminate/support Version ^5.4 | ^6.0
illuminate/console Version ^5.4 | ^6.0
league/pipeline Version ^0.3.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 nordsoftware/lumen-elasticsearch contains the following files

Loading the files please wait ....