PHPackages                             hch/elastic-ml-bundle - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. hch/elastic-ml-bundle

ActiveSymfony-bundle[API Development](/categories/api)

hch/elastic-ml-bundle
=====================

A Symfony bundle to integrate Elastic Machine Learning.

v1.0.0(1y ago)115MITPHPPHP &gt;=7.4

Since Oct 16Pushed 1y ago1 watchersCompare

[ Source](https://github.com/lechaabani/ElasticMlBundle)[ Packagist](https://packagist.org/packages/hch/elastic-ml-bundle)[ RSS](/packages/hch-elastic-ml-bundle/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (3)Versions (2)Used By (0)

hch/elastic-ml-bundle
=====================

[](#hchelastic-ml-bundle)

Introduction
------------

[](#introduction)

The **ElasticMlBundle** is a Symfony bundle that integrates **Elastic Machine Learning** (ML) features from Elasticsearch into your Symfony application. This bundle allows you to create and manage Machine Learning jobs via Elasticsearch's ML API.

Features
--------

[](#features)

- Create ML jobs in Elasticsearch
- Retrieve ML job results
- Flexible configuration for Elasticsearch hosts
- Example Symfony command to easily create jobs via the CLI

Installation
------------

[](#installation)

1. **Install the bundle via Composer**:

    ```
    composer require hch/elastic-ml-bundle
    ```
2. **Enable the bundle in config/bundles.php**:

    ```
    return [
    	Hch\ElasticMLBundle\ElasticMLBundle::class => ['all' => true],
    ];

    ```
3. **Configure the Elasticsearch host in config/packages/elastic\_ml.yaml**:

    ```
    elastic_ml:
        host: 'http://localhost:9200'
    ```

Usage
-----

[](#usage)

Creating an ML Job via Symfony Command:

```
php bin/console elastic:ml:create-job --jobId=my-job-id --index=my-index

```

Example Output:

```
Job created successfully!

```

- Handling Elasticsearch Exceptions: In case of errors such as misconfigured requests or Elasticsearch being down, you will receive detailed error messages from the API.

Troubleshooting:
----------------

[](#troubleshooting)

- 403 Forbidden: License non-compliant for ML: If you encounter this error, it means your Elasticsearch license does not support Machine Learning. You have the following options:

Activate a trial license:

```
curl -X POST "http://localhost:9200/_license/start_trial?acknowledge=true"

```

. Upgrade your Elasticsearch license to a Gold or Platinum subscription to access ML features.

. No alive nodes: All the nodes seem to be down: This error indicates that Elasticsearch is either not running or unreachable.

Ensure Elasticsearch is running:

```
   sudo systemctl start elasticsearch

```

If using Docker, ensure the container is running:

```
   docker start

```

- Invalid job request: analysis\_config doesn't support START\_ARRAY: This error occurs when the analysis\_config in the request is incorrectly formatted. Ensure the detectors field in analysis\_config is an array of objects. Here's a valid example:

    analysis\_config: bucket\_span: "5m" detectors: - function: "mean" field\_name: "response\_time"

Configuration
-------------

[](#configuration)

- Ensure correct Elasticsearch configuration in config/packages/elastic\_ml.yaml:

    elastic\_ml: host: ''

Development
-----------

[](#development)

Code Structure:

- Service: The service ElasticMLService provides the core functionalities to create ML jobs and retrieve results from Elasticsearch.
- The constructor takes the Elasticsearch host URL as a parameter.
- Command: The Symfony command CreateMLJobCommand uses the service to create ML jobs via the CLI.
- Example Service Usage: In your Symfony controllers or services, you can use the ElasticMLService like this:

    $mlService = $this-&gt;get(ElasticMLService::class); $params = \[ 'job\_id' =&gt; 'my-job-id', 'analysis\_config' =&gt; \[ 'bucket\_span' =&gt; '5m', 'detectors' =&gt; \[ \[ 'function' =&gt; 'mean', 'field\_name' =&gt; 'response\_time' \] \] \], 'data\_description' =&gt; \[ 'time\_field' =&gt; '@timestamp' \], 'datafeed\_config' =&gt; \[ 'indices' =&gt; \['my-index'\] \] \]; $mlService-&gt;createJob($params);

Testing
-------

[](#testing)

```
php bin/phpunit

```

Future Enhancements
-------------------

[](#future-enhancements)

- Allow users to pass dynamic job parameters via the Symfony command.
- Extend the bundle to support other machine learning engines, such as Google AI or AWS SageMaker.
- Automatically handle license upgrades or fallback gracefully when ML features are unavailable.

License
-------

[](#license)

This bundle is licensed under the MIT License. See LICENSE for more information.

###  Health Score

24

—

LowBetter than 32% of packages

Maintenance37

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity39

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

577d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/7e8d866baf77d018f6f41d6dfe3fd8104dfe49a30b5c717bad62cefd1d8a3d43?d=identicon)[Hamadi](/maintainers/Hamadi)

---

Top Contributors

[![lechaabani](https://avatars.githubusercontent.com/u/3493399?v=4)](https://github.com/lechaabani "lechaabani (1 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/hch-elastic-ml-bundle/health.svg)

```
[![Health](https://phpackages.com/badges/hch-elastic-ml-bundle/health.svg)](https://phpackages.com/packages/hch-elastic-ml-bundle)
```

###  Alternatives

[sylius/sylius

E-Commerce platform for PHP, based on Symfony framework.

8.4k5.6M651](/packages/sylius-sylius)[wheelpros/fitment-platform-api

Magento 2 (Open Source)

12.1k1.2k](/packages/wheelpros-fitment-platform-api)[cravler/maxmind-geoip-bundle

Bundle integrating MaxMind GeoIP2 database into symfony application

27615.8k2](/packages/cravler-maxmind-geoip-bundle)[sulu/headless-bundle

Bundle that provides controllers and services for using Sulu as headless content management system

55133.7k2](/packages/sulu-headless-bundle)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
