Download the PHP package josbeir/cakephp-elastickit without Composer

On this page you can find all versions of the php package josbeir/cakephp-elastickit. 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 cakephp-elastickit

ElasticKit - a CakePHP Elasticsearch plugin

CI PHPStan codecov Minimum PHP Version Packagist Downloads GitHub License

[!IMPORTANT] This plugin is now archived as I have proceeded on maintaining the official CakePHP elastic-search plugin.

A lightweight CakePHP 5 plugin for working with Elasticsearch using the official PHP client.

Table of Contents

Design Philosophy

This plugin provides minimal abstraction over the official Elasticsearch client. It handles connection management, index location, and result decoration while leaving persistence and validation to you.

Not included: ORM-style persistence, validation, or RepositoryInterface implementation.

Want full ORM features? Use cakephp/elastic-search instead, which provides an ORM similar to CakePHP's database layer.

Why this plugin?

How it differs from the original cakephp/elastic-search plugin

cakephp/elastic-search (Elastica-based) provides a full ORM experience with types, persistence, and validation. ElasticKit takes a minimal approach:

Use the original plugin for ORM-style features. Use ElasticKit for clean access to the official client with CakePHP conveniences.

Requirements

Note: Lock the elasticsearch/elasticsearch package version in your composer file to match your Elasticsearch server version for optimal compatibility:

Installation

Install the dependencies in your Cake app:

Ensure the plugin is loaded (one of):

Configuration

Register an Elasticsearch connection using the plugin’s connection class. You can do this in config/bootstrap.php or in a config file loaded during bootstrap:

By default, indices resolve to the elasticsearch connection name. You can override the connection per index class via options if needed.

HTTP Client Configuration

By default, the connection uses CakePHP's Http Client, which makes it easy to mock requests during testing. You can override this behavior using the httpClient option:

Defining an Index

Create an index class in src/Model/Index, e.g. ArticlesIndex:

Document Entities

Document entities are resolved automatically from your index name. For an index named articles, the plugin will try App\Model\Document\Article. If not present, it falls back to the generic ElasticKit\Document.

Document entities follow CakePHP's EntityInterface with one key difference: the document ID and score are stored in a reserved property to avoid field name collisions.

Access these properties using:

Querying

You can query in two ergonomic ways.

1) With Spatie’s query builder

The Index::find() method creates a Spatie\ElasticsearchQueryBuilder\Builder, sets the index, executes the search, and returns a ResultSet that yields Document instances.

2) Directly via the official client

Every unknown method call on your index instance proxies to the underlying Elastic\Elasticsearch\Client, so you can use the full API. Note that while get() is reserved by the Index class for fetching single documents, you can still access the client's get() method via getClient()->get():

Convenience methods

The ResultSet exposes helpers like:

ResultSet API

ElasticKit\ResultSet is an iterator over decorated Document instances and provides a few helpers around the Elasticsearch response.

Iteration

Force a specific document class

Note: ResultSet also includes common collection utilities via Cake’s CollectionTrait (e.g., map(), filter(), toList()), which can be handy for quick transformations.

CLI: manage indices

The plugin ships a small command to create/update/delete indices based on your index class config (settings/mappings).

Use -v to print current settings/mappings of the target index.

Accessing indices from your code

Use the IndexLocatorAwareTrait to fetch indices by alias (class name without the Index suffix):

PHPstan notes

When using IndexLocatorAwareTrait::fetchIndex(), PHPStan will complain about assign.propertyType when assigning the result to a typed property. This happens because PHPStan can't infer the specific index class being returned.

To resolve this while maintaining similarity with IndexLocatorAwareTrait::fetchTable(), add the following to your phpstan.neon configuration (requires cakedc/cakephp-phpstan):

This extension teaches PHPStan to recognize that $this->fetchIndex('Articles') returns an ArticlesIndex instance, eliminating type errors.

Logging and debugging

DebugKit panel

This plugin includes a DebugKit panel that displays Elasticsearch requests per configured connection.

To enable the panel, add it to your DebugKit configuration:

What this plugin does NOT do

This is by design to keep the integration thin, explicit, and resilient to upstream changes.

Contributing

Contributions are welcome! Please feel free to submit a Pull Request. For major changes, please open an issue first to discuss what you would like to change.

Development Setup

  1. Clone the repository
  2. Install dependencies: composer install
  3. Run tests: composer test

Please make sure to update tests as appropriate and follow the existing code style.

License

This project is licensed under the MIT License - see the LICENSE file for details.


All versions of cakephp-elastickit with dependencies

PHP Build Version
Package Version
Requires php Version >=8.2
cakephp/cakephp Version ^5.2
elasticsearch/elasticsearch Version ^8.5 || ^9.0
spatie/elasticsearch-query-builder Version ^3.8
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 josbeir/cakephp-elastickit contains the following files

Loading the files please wait ...