Packagist (self-heallm/php-self-heallm)
GitHub (universe-coder/php-self-heallm)
Canonical repository URLs are in composer.json (homepage, support). The Composer package name on Packagist remains self-heallm/php-self-heallm.
Framework-agnostic PHP Composer library that scans recent log errors, asks an LLM for a fix (OpenAI, Anthropic, Hugging Face OpenAI-compatible endpoint, or Ollama), validates path safety, optionally applies patches, and sends reports (Telegram, Slack, webhook, Sentry, JSONL file).
composer require self-heallm/php-self-heallmFrom your project root (with config/self-heal.php or env vars):
vendor/bin/self-healOr pass an explicit config path:
vendor/bin/self-heal --config=/absolute/path/to/self-heal.phpCopy config/self-heal.php into your app and adjust paths under log, reporting, and deduplication defaults (package defaults use <package>/var/... when shipped alone).
use SelfHealLM\Bootstrap\SelfHealApplication;
$pipeline = SelfHealApplication::fromConfigFile(__DIR__ . '/config/self-heal.php');
$result = $pipeline->run(); // ['status' => 'ok'|'skipped', 'reason' => ...?]Or build config in memory:
$pipeline = SelfHealApplication::fromConfigArray([
'enabled' => true,
'dry_run' => true,
'log' => ['path' => '/var/log/app.log', 'max_lines' => 200],
// ... same keys as in config/self-heal.php (no outer `self-heal` key required)
]);Same SELF_HEAL_* names as the Laravel-oriented package; see config/self-heal.php for the full list. Set SELF_HEAL_OPENAI_TOKEN, SELF_HEAL_LOG_PATH, etc., in your process environment or .env loader before including the config file.
- Only paths under configured
allowed_pathsare accepted;forbidden_pathsalways win. - Auto-apply runs only when
enabled,auto_apply, anddry_runare set accordingly in config.
The laravel-self-heallm package targets Laravel apps; this library is suitable for any PHP runtime with Composer.
MIT. See LICENSE.