Download the PHP package fruitcake/magento2-health-check without Composer

On this page you can find all versions of the php package fruitcake/magento2-health-check. 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 magento2-health-check

Magento 2 Health Check

A health check endpoint for Magento 2 at /health, similar to Laravel's /up route. Other modules can add their own checks through an event.

Screenshot 2026-11-09 at 14 00 47@2x

Install

Usage

Status HTTP
pass 200
warn 200
fail 503
wrong key 403, {"error":"Forbidden"}

The response is JSON in the format of draft-inadarei-api-health-check, sent as application/health+json. It is never cached.

With a key set, the response lists every check:

With details, the response also has version, the Magento version and edition, serviceId, the hostname of the node that answered, and releaseId, the static content version from pub/static/deployed_version.txt. setup:static-content:deploy writes that file on every deploy, whatever the deploy tool, so after a deploy you can see whether every node runs the same release. releaseId is left out when the file does not exist, e.g. in developer mode.

With details, a warn or fail response also gets a top-level output with every check that did not pass, failures first, so a monitor shows the reason without digging through checks:

Each check holds a list with one check object, as the draft prescribes, followed by its measurements as <check>:<measurement> with observedValue and observedUnit. output holds the message for warn and fail only. Checks that talk to a service (database, cache and session storage, search engine, RabbitMQ) add <check>:responseTime in ms. meta is an addition of this module.

Oh Dear

The endpoint also speaks the format of Oh Dear's Application Health monitoring. In Oh Dear, set the health check URL to the endpoint and the secret to the key. Oh Dear sends the key in the oh-dear-health-check-secret header, which gets that format; ?format=ohdear does the same for testing. The response is always HTTP 200, as the status of each check is in the body, and 403 for a wrong secret. Every check becomes a check result; nested meta values are joined into one string, as Oh Dear shows meta as keys and values. Without details, the only result is health with the overall status.

In a browser

Opened in a browser, the endpoint shows an HTML page: the status, a table of the checks, and the JSON. Browsers are recognised by the Sec-Fetch-Dest: document header, which monitors do not send, even the ones that pretend to be a browser, like StatusCake. Monitors that use a real browser get JSON by their user agent: StatusCake, UptimeRobot, Pingdom, Oh Dear, Checkly, Better Stack and others are built in, and Monitor User Agents in the configuration adds more. ?format=json or ?format=html overrides the detection. The HTTP status is the same, and the page holds the JSON too, so a keyword check on e.g. "pass" still matches.

Defaults

The module works right after install: /health is public, returns only the overall status and runs every check below. No check is strict, so warnings never turn the endpoint red.

Configuration

Stores > Configuration > Fruitcake Extensions > Health Check:

The same paths work with bin/magento config:set, e.g. config:set fruitcake_healthcheck/checks/search_engine 0 or config:set fruitcake_healthcheck/checks/cron strict_production.

Checks

Code Fails when Warns when
database no connection 80% of max_connections is in use. Measures connections and connectionsUsed
cache_storage a cache frontend (default, page_cache) cannot write and read back a value. For Redis frontends it measures memory use and evicted keys
session_storage the session storage Magento uses (files, Redis or database) cannot write and read back a session no storage test exists for the handler (e.g. memcached), or database sessions without garbage collection (session.gc_probability = 0), so the session table keeps growing, or the session Redis evicted keys, which logs customers out
cache_types a cache type is disabled or invalidated
search_engine OpenSearch/Elasticsearch (Magento's own, Amasty Elastic Search or Smile ElasticSuite) does not answer a ping, or its cluster health is red (primary shards missing) no connection test exists for the configured engine, or the cluster health is yellow on more than one data node
rabbitmq no connection to RabbitMQ with queue/amqp from env.php (passes without connecting when it is not configured)
mysql_queue 1000 or more messages wait in Magento's MySQL queues (Magento_MysqlMq), i.e. a consumer does not run. Measures waiting, retry and failed
indexers an indexer is invalid or its changelog backlog is over the threshold
cron no cron job finished within the threshold (15 minutes). The module adds an index on cron_schedule (status, finished_at) so this stays fast on a large table
deploy_mode not in production mode, or the Composer autoloader is not optimized (composer dump-autoload --optimize)
debug template hints, debug logging, inline translation, a database profiler or static_content_on_demand_in_production is on
public_files pub/ or pub/media/ holds database dumps, archives, phpinfo.php, .git, .env, composer.json or auth.json
disk_space free space on var/ below 2% free space below 10%
opcache OPcache is off, its status is not available (opcache.restrict_api), 90% of its memory or keys (opcache.max_accelerated_files) is used, or the hit rate is below 90% after 10,000 requests. The result is per web node
two_factor_auth admin two-factor authentication is off: Magento_TwoFactorAuth is disabled, or twofactorauth/general/enable is 0 (e.g. MarkShust_DisableTwoFactorAuth). Use Yes, warnings fail in production mode to fail on production only

A check that throws an exception counts as failed, also an observer that does not extend AbstractCheck; the checks after it still run. Failed checks are logged, the same failure at most once every 5 minutes.

session_storage tests the handler Magento actually uses. Magento only knows db and redis in session/save; another value, e.g. database, gives PHP's own handler (usually files), and meta then shows both handler and configured. It tests the handler itself. Magento falls back to file sessions when Redis is down, so the shop seems to work while every node keeps its own sessions and customers get logged out. For file sessions it writes in the save path PHP uses, including the subdirectories of a N;/path save path.

Security

Adding a check

Extend AbstractCheck and listen to fruitcake_healthcheck_diagnose:

Report measured values as measurements, not in meta: CheckResult::ok()->withMeasurement('hitRate', 99.5, 'percent'). They appear as "<code>:<name>" with observedValue and observedUnit, as draft-inadarei-api-health-check prescribes, e.g. "opcache:hitRate": [{"observedValue": 99.5, "observedUnit": "percent", "status": "pass"}], with the status of the check. Use meta for the rest, like names and modes. A check that talks to a service can override measuresResponseTime() to return true, which adds <code>:responseTime.

To make it configurable in the admin, add a field to the fruitcake_healthcheck/checks group in your own system.xml, with Fruitcake\HealthCheck\Model\Config\Source\CheckMode as source model.

Search engines

The search_engine check asks each tester in the pool whether it knows the configured engine. Magento's own OpenSearch/Elasticsearch, Amasty Elastic Search and Smile ElasticSuite are built in. Add a tester for another engine by implementing Fruitcake\HealthCheck\Model\SearchEngine\ConnectionTesterInterface (return null for engines it does not know) and adding it in di.xml:

Without AbstractCheck

An observer that does not extend AbstractCheck gets the report with $observer->getData('report') and calls $report->add('code', CheckResult::warning('...')).

Adding a format

The response formats (json, ohdear, html) are a pool in di.xml. Add one by implementing Fruitcake\HealthCheck\Model\Format\FormatInterface:

?format=prometheus then picks it. Without ?format=, the first format whose matches() is true wins, in the order of the pool, and json is the default. The key is checked before any format runs; a wrong key always gets 403 JSON.

Tests

Composer gets the Magento packages from the public Mage-OS mirror, so no repo.magento.com credentials are needed. That repository only applies when developing this package; projects installing it use their own.


All versions of magento2-health-check with dependencies

PHP Build Version
Package Version
Requires php Version ^8.1
magento/framework Version ^103.0
magento/framework-amqp Version *
magento/module-advanced-search Version *
magento/module-backend Version *
magento/module-config Version *
magento/module-cron Version *
magento/module-indexer Version *
magento/module-search Version *
magento/module-store Version *
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 fruitcake/magento2-health-check contains the following files

Loading the files please wait ...