Download the PHP package mailerlite/laravel-elasticsearch without Composer

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

Laravel-Elasticsearch

An easy way to use the official Elastic Search client in your Laravel applications.

Build Status Total Downloads Latest Stable Version

Requirements

Installation

Install the current version of the mailerlite/laravel-elasticsearch package via composer:

This version of the package targets Elasticsearch 8.x. If you are running an older version of Elasticsearch, install the matching major version of this package:

Elasticsearch Package version
8.x ^12
7.x ^11

For example, to use Elasticsearch 7, install version ^11. Its documentation lives on the 11.x branch:

[!NOTE] Upgrading from Elasticsearch 7? Version 12 moves to the Elasticsearch 8.x client, which introduces breaking changes (new namespace, response objects and removed configuration options). See UPGRADING.md for the full migration guide.

Configuration

The package's service provider is registered automatically.

Publish the configuration file:

Alternative configuration method via .env file

After you publish the configuration file as suggested above, you may configure ElasticSearch by adding the following to your application's .env file (with appropriate values):

If you are logging in via API keys, you will need to fill in these values:

Connecting to AWS Elasticsearch Service

If you are connecting to ElasticSearch instances on Amazon AWS, then you'll also need to composer require aws/aws-sdk-php:^3.80 and add the following to your .env file:

If you have to use another authentication method having custom credentials (i.e. instanceProfile()), you have to publish the configuration file and use the aws_credentials:

If you have a job that runs in supervisor, you have to use the Closure. This way the credentials will be renewed at runtime.

If you are using php artisan config:cache, you cannot have the Closure in your config file, call it like this:

Security and TLS (Elasticsearch 8.x)

Elasticsearch 8 enables TLS and authentication by default. When connecting to a secured cluster you typically need to:

Usage

The Elasticsearch facade is just an entry point into the ES client, so previously you might have used:

You can now replace those last two lines with simply:

That will run the command on the default connection. You can run a command on any connection (see the defaultConnection setting and connections array in the configuration file).

The official Elasticsearch 8.x client no longer returns plain arrays. Every call returns an Elastic\Elasticsearch\Response\Elasticsearch object that implements ArrayAccess, so you can keep accessing keys directly ($return['_id']) or convert it explicitly. By default the client also throws an Elastic\Elasticsearch\Exception\ClientResponseException on 4xx responses and a ServerResponseException on 5xx responses. For HEAD-style endpoints such as indices()->exists() and ping(), resolve the result with ->asBool().

Convert a response explicitly with one of:

For example, running a search and reading the hits:

Instead of the facade, you can also use dependency injection or the application container to get the ES service object:

Advanced Usage

Because the package is a wrapper around the official Elastic client, you can do pretty much anything with this package. Not only can you perform standard CRUD operations, but you can monitor the health of your Elastic cluster programmatically, back it up, or make changes to it. Some of these operations are done through "namespaced" commands, which this package happily supports.

To grab statistics for an index:

To create and restore snapshots (read the Elastic docs about creating repository paths and plugins first):

To delete whole indices (be careful!):

Please remember that this package is a thin wrapper around a large number of very sophisticated and well-documented Elastic features. Information about those features and the methods and parameters used to call them can be found in the Elastic documentation. Help with using them is available via the Elastic forums and on sites like Stack Overflow.

Console commands

This package also provides some useful console commands.

Check if an index exists:

Create an index:

Delete an index:

Create or update index mapping: Note: The index mapping file must contain a valid JSON mapping definition as Elasticsearch expects, for example:

Creates an alias:

Remove index from an alias:

Switch index on alias (useful for zero-downtime release of the new index):

Bugs, Suggestions, Contributions and Support

Thanks to everyone who has contributed to this project!

Please use Github for reporting bugs, and making comments or suggestions.

See CONTRIBUTING.md for how to contribute changes.

Copyright and License

laravel-elasticsearch was written thanks to Colin Viebrock and is released under the MailerLite

Copyright (c) 2026 MailerLite


All versions of laravel-elasticsearch with dependencies

PHP Build Version
Package Version
Requires php Version ^8.2
ext-json Version *
elasticsearch/elasticsearch Version ^8.0
guzzlehttp/guzzle Version ^7.0
guzzlehttp/psr7 Version ^2.0
illuminate/contracts Version ^11.0|^12.0|^13.0
illuminate/support Version ^11.0|^12.0|^13.0
psr/http-message Version ^1.1|^2.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 mailerlite/laravel-elasticsearch contains the following files

Loading the files please wait ...