Installation
Requirements
Section titled “Requirements”- PHP 8.3 or higher
- Git installed and accessible from command line
- Laravel: Laravel 12.x or 13.x
- WordPress: WP-CLI 2.8+
Installation
Section titled “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
Section titled “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
Section titled “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 the Development Version
Section titled “Installing the Development Version”All three packages (codemetry/core, codemetry/laravel and codemetry/wordpress) are on Packagist. To try changes that haven’t been released yet, require the dev-main branch:
composer require codemetry/laravel:dev-main --devSwitch back to a tagged release (for example ^1.5) for anything you depend on.
Troubleshooting
Section titled “Troubleshooting”Command not found
Section titled “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
Section titled “Git 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
Section titled “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