Installation
Requirements
- PHP 8.2 or higher
- Git installed and accessible from command line
- Laravel: Laravel 11.x or 12.x
- WordPress: WP-CLI 2.8+
Installation
Codemetry is a development/analysis tool—it analyzes your Git history but isn’t needed in production. Install it as a dev dependency.
-
Install via Composer
Terminal window composer require codemetry/laravel --devThe service provider is auto-discovered—no manual registration needed.
-
Publish the configuration (optional)
Terminal window php artisan vendor:publish --tag=codemetry-configThis creates
config/codemetry.phpwhere you can customize:- Baseline days (default: 56)
- Follow-up horizon (default: 3 days)
- Keyword patterns for fix/revert/wip detection
- AI engine settings
-
Verify installation
Terminal window php artisan codemetry:analyze --days=1If you see a table with mood results, you’re all set!
-
Install via WP-CLI or Composer
Terminal window # Option 1: WP-CLI package managerwp package install codemetry/wordpress# Option 2: Composercomposer require codemetry/wordpress --dev -
Configure via wp-cli.yml (optional)
Create
wp-cli.ymlin your project root:codemetry:baseline_days: 56ai:enabled: falseengine: openaiapi_key: ${CODEMETRY_AI_API_KEY} -
Verify installation
Terminal window wp codemetry analyze --days=1If you see a table with mood results, you’re all set!
Configuration File
After publishing, you’ll have config/codemetry.php:
return [ // Days of history for baseline distribution 'baseline_days' => 56,
// Days after a window to scan for follow-up fixes 'follow_up_horizon_days' => 3,
// Commit message patterns 'keywords' => [ 'fix_pattern' => '/\b(fix|bug|hotfix|patch|typo|oops)\b/i', 'revert_pattern' => '/\b(revert)\b/i', 'wip_pattern' => '/\b(wip|tmp|debug|hack)\b/i', ],
// AI configuration (optional) 'ai' => [ 'enabled' => false, 'engine' => env('CODEMETRY_AI_ENGINE', 'openai'), 'api_key' => env('CODEMETRY_AI_API_KEY'), 'model' => env('CODEMETRY_AI_MODEL'), 'base_url' => env('CODEMETRY_AI_BASE_URL'), // Custom API endpoint 'timeout' => env('CODEMETRY_AI_TIMEOUT', 30), // Request timeout ],];Upgrading
Both codemetry/laravel and codemetry/core must be updated together to ensure compatibility. Use one of these commands:
# Update all Codemetry packagescomposer update "codemetry/*"
# Or explicitlycomposer update codemetry/laravel codemetry/coreInstalling from GitHub (Pre-Release)
If the package isn’t on Packagist yet, install directly from GitHub:
{ "repositories": [ { "type": "vcs", "url": "https://github.com/albertoarena/codemetry" } ], "minimum-stability": "dev", "prefer-stable": true, "require-dev": { "codemetry/laravel": "dev-master" }}Then run:
composer updateTroubleshooting
Command not found
If php artisan codemetry:analyze returns “Command not found”, the service provider may not be loaded. Try:
php artisan package:discover --ansiGit errors
Codemetry requires Git access. Ensure:
- You’re running the command from a Git repository
- The
gitcommand is available in your PATH - The repository has commit history (not a fresh init)
Memory issues on large repos
For repositories with extensive history, the baseline calculation may use significant memory. Try:
- Reducing
baseline_daysin config - Running with increased PHP memory:
php -d memory_limit=512M artisan codemetry:analyze