Download the PHP package php-es-orm/es-orm without Composer

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

php-es-orm

An Eloquent-style, type-safe, production-ready Elasticsearch ORM for PHP.

php-es-orm gives you a Laravel Eloquent-like developer experience on top of Elasticsearch, without hiding what Elasticsearch can do. It keeps the native Query DSL, Aggregations, search_after, Point In Time (PIT), Bulk, Aliases, Reindex and everything else within reach — and never pretends Elasticsearch is MySQL.


Table of contents

  1. Requirements
  2. Installation
  3. Configuration
  4. Connecting to Elasticsearch
  5. Creating a Model
  6. CRUD
  7. Query Builder
  8. Query DSL
  9. Bool queries
  10. Nested queries
  11. Raw DSL
  12. Source filtering
  13. Sorting
  14. Operators
  15. Pagination
  16. Aggregations
  17. Highlight
  18. Suggest
  19. Geo search
  20. Scroll
  21. Bulk
  22. MGET & Multi Search
  23. Casts
  24. Accessors & Mutators
  25. Fillable / Guarded
  26. Scopes
  27. Soft deletes
  28. Events & Observers
  29. Relations
  30. Mapping
  31. Index management
  32. Alias management
  33. Reindex
  34. Index migrations
  35. Caching
  36. Debugging
  37. Error handling
  38. Laravel integration
  39. Docker & tooling
  40. Testing
  41. FAQ
  42. Architecture

Requirements

Installation

You also need a PSR-18 HTTP client (Guzzle is the usual choice):

Configuration

The package ships with a configuration file you can copy into your project:

Supported connection keys: hosts, cloud_id, api_key (+ optional api_key_id), username/password, bearer_token, http_client, http_client_options, timeout, connect_timeout, ssl_certificate, ssl_key, ssl_ca, ssl_verification, logger.

Authentication recap — Basic Auth (username + password), API Key (api_key), Bearer Token (bearer_token), Cloud ID (cloud_id) and TLS (ssl_*) are all supported.

Connecting to Elasticsearch

Standalone PHP

Models resolve a shared connection manager lazily from config/es_orm.php (relative to the current working directory) or from the file pointed at by the ES_ORM_CONFIG environment variable:

You can also inject the manager explicitly (recommended in tests and in custom bootstrapping):

Laravel

Nothing to do beyond installing the package — the service provider is auto-discovered. See Laravel integration.

Creating a Model

The index defaults to the snake-cased class name plus s when $index is not set.

CRUD

Find-or-create helpers

Atomic counters

increment() / decrement() write the change with a single Painless script update (retry_on_conflict included), so concurrent writers never lose an update, and the in-memory attributes stay in sync:

Batch operations (Bulk API)

All batch helpers use the Elasticsearch Bulk API in a single request per chunk — they never loop over single-document calls:

The chunk size defaults to bulk.chunk_size (1000) and can be overridden per call: User::bulkCreate($docs, 500).

Query Builder

Every where() appends to the current AND group; every orWhere() starts a new group. Nested closures reuse the exact same builder:

Available where helpers:

Execution helpers

sole() throws ModelNotFoundException when nothing matches and MultipleRecordsFoundException when more than one document matches.

Query DSL

The native Elasticsearch queries are first-class citizens:

Bool queries

The Eloquent-style closure form and the explicit bool-occurrence form both compile to the Elasticsearch bool DSL:

Nested queries

Raw DSL

Anything the ORM does not wrap is still reachable, and it can be mixed with the ORM API in the same query. Raw DSL is an advanced API — your input is sent as-is.

Source filtering

Sorting

Operators

ORM operator Elasticsearch DSL
=, == term
!=, <> bool.must_not / term
>, >=, <, <= range
like wildcard (% → *)
not like bool.must_not / wildcard
in terms
not in bool.must_not / terms

Pagination

Deep pagination primitives:

Elasticsearch's from + size pagination is capped (index.max_result_window, 10 000 by default). Prefer cursorPaginate() / search_after() / pit() for large result sets.

Aggregations

Shorthand builders:

Complex, nested aggregations:

Highlight

Suggest

Geo search

Scroll

each() scrolls automatically when no searchAfter()/pit() is configured, and uses search_after (with a PIT) otherwise. Scroll handles are always cleared:

Bulk

Individual failures are surfaced through EsOrm\Exceptions\BulkException (->failures()).

MGET & Multi Search

Casts

Supported cast names: integer/int, float/double/decimal, boolean/bool, string, array, json, object/map, datetime/date_time/timestamp, date.

Accessors & Mutators

The getter also receives the whole attribute array as its second argument, so cross-field accessors are possible. The method must declare an Attribute return type to be recognised.

Fillable / Guarded

Scopes

Local scopes are plain methods prefixed with scope:

Object scopes implement EsOrm\Scope\Scope; global scopes are registered on the model and applied to every query:

Soft deletes

Events & Observers

Model events are dispatched through EsOrm\Events\EventDispatcher: creating, created, saving, saved, updating, updated, deleting, deleted, restoring, restored, forceDeleting, forceDeleted.

A Laravel application may replace the dispatcher with a bridge to the framework event system via Model::setEventDispatcher().

Relations

Relations are a batch-aware convenience layer (not SQL joins) designed so eager loading never triggers an N+1:

Available: HasOne, HasMany, BelongsTo. Nested eager loads are supported via dot notation (Article::with('author.company')).

Mapping

A model declares its mapping; convert it to an index body with mappingDefinition() or hand the raw array to the IndexManager.

Or build a mapping fluently:

Index management

Alias management

Reindex

Index migrations

Run them through the framework-agnostic runner:

Or via Artisan (Laravel): php artisan es:migrate, php artisan es:migrate:rollback, php artisan es:migrate:status.

Caching

Query caching is disabled by default. Enable it with an opt-in per query and a configurable driver implementing EsOrm\Contracts\CacheStoreInterface:

Debugging

The connection records every request (HTTP method, endpoint, index, body, duration and errors) into EsOrm\Support\QueryLog when logging.enabled is on.

Error handling

Exception Thrown when
ConnectionException transport failure, server 5xx, retry exhaustion
QueryException a non-index / non-bulk request failed
IndexException an index-level request failed
BulkException a bulk request failed (->failures() exposes per-item errors)
MappingException an invalid mapping or unsupported cast type
InvalidQueryException an invalid builder call / unknown operator
ModelNotFoundException findOrFail() / firstOrFail() found nothing
ValidationException invalid input rejected before hitting Elasticsearch
SearchException, PaginationException, DslException, ReindexException other specific failures

All extend EsOrm\Exceptions\EsOrmException.

Laravel integration

The core has no Laravel dependency; the integration is an adapter registered by package discovery.

Publish the config:

Models work unchanged inside a Laravel project.

Docker & tooling

docker-compose.yml provides Elasticsearch 8.15 and Kibana (profile kibana).

Testing

FAQ

Do I need Laravel to use this package? No. The core ORM is framework agnostic. Laravel is an optional adapter.

Does it replace the Elasticsearch Query DSL? No. The DSL is fully reachable, and rawQuery() / raw() let you pass any DSL the ORM does not wrap.

How do I avoid deep pagination problems? Use cursorPaginate(), searchAfter() or pit() instead of large offset() values.

Are bulk operations really batched? Yes — every bulkCreate()/bulkUpdate()/bulkDelete() call issues Bulk API requests, one per chunk.

How do I change the default page size? Set pagination.default_size in config/es_orm.php, or pass it to paginate().

Is rawQuery() safe? It is an advanced API: input is forwarded to Elasticsearch as-is. Use it only with trusted input; normal user input should go through the DSL builder.

Architecture

This separation keeps the API stable and lets new Elasticsearch features be added without breaking existing code.

License

MIT — see LICENSE.


All versions of es-orm with dependencies

PHP Build Version
Package Version
Requires php Version ^8.2
ext-json Version *
elasticsearch/elasticsearch Version ^9.5
psr/log Version ^1.1 || ^2.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 php-es-orm/es-orm contains the following files

Loading the files please wait ...