PHP Classes

How to Use a PHP Code Checker AI Client to Report the Quality of the Code in a Git Repository Using the Package Codemetry Laravel: Analyse the quality of code in a Git repository

Recommend this page to a friend!
  Info   Documentation   View files Files   Install with Composer Install with Composer   Download Download   Reputation   Support forum   Blog    
Last Updated Ratings Unique User Downloads Download Rankings
2026-05-17 (1 month ago) RSS 2.0 feedNot yet rated by the usersTotal: Not yet counted Not yet ranked
Version License PHP version Categories
codemetry-laravel 1.0MIT/X Consortium ...7Tools, Web services, Artificial intel..., P...
Description 

Author

This package can analyse the quality of code in a Git repository.

It provides a command that can be used by Laravel Artisan to analyze several types of code quality metrics from the command line console.

The command can analyze the quality of the code using an artificial intelligence prompt service API (like OpenAI, Anthropic, DeepSeek, and Google Gemini) and outputs the results on a table or in JSON format.

Innovation Award
PHP Programming Innovation award nominee
May 2026
Number 7
Tools to analyze the code of a software project can be good to help developers understand parts of their code that they can change to improve the code quality.

This package provides a code analysis tool that uses artificial intelligence services to analyze and report on aspects of the quality of the code of a project hosted in a Git repository.

Manuel Lemos
Picture of Alberto Arena
  Performance   Level  
Name: Alberto Arena <contact>
Classes: 4 packages by
Country: Italy Italy
Age: ???
All time rank: Not yet ranked
Week rank: Not yet ranked
Innovation award
Innovation award
Nominee: 2x

Instructions

Documentation

Codemetry Laravel

Laravel adapter for Codemetry - provides Artisan commands and service provider integration for Git repository analysis.

This package depends on codemetry/core.

Documentation | Getting Started

Requirements

  • PHP 8.2+
  • Laravel 11.x or 12.x
  • Git

Installation

composer require codemetry/laravel

This automatically installs codemetry/core as a dependency.

Publish the configuration file:

php artisan vendor:publish --tag=codemetry-config

Upgrading

Both codemetry/laravel and codemetry/core must be updated together to ensure compatibility:

composer update "codemetry/*"

Or explicitly:

composer update codemetry/laravel codemetry/core

> Note: Running composer update codemetry/laravel alone may not work because both packages are versioned together and require matching versions.

Usage

# Table output (one row per day)
php artisan codemetry:analyze --days=7

# JSON output
php artisan codemetry:analyze --days=7 --format=json

# Filter by author or branch
php artisan codemetry:analyze --days=7 --author="Jane Doe" --branch=main

# Specify date range
php artisan codemetry:analyze --since=2024-01-01 --until=2024-01-31

# Enable AI-powered explanations (requires API keys in config)
php artisan codemetry:analyze --days=7 --ai=1

Configuration

After publishing, edit config/codemetry.php:

return [
    // Number of days to analyze by default
    'days' => 7,

    // Baseline period for normalization (in days)
    'baseline_days' => 56,

    // Follow-up fix detection horizon (in days)
    'follow_up_horizon_days' => 3,

    // AI configuration (optional)
    'ai' => [
        'enabled' => false,
        'engine' => 'openai', // openai, anthropic, deepseek, google
        'api_key' => env('CODEMETRY_AI_API_KEY'),
    ],
];

AI Integration

AI integration is opt-in and metrics-only. Engines never receive raw code or diffs.

Supported engines: - OpenAI - Anthropic (Claude) - DeepSeek - Google

When AI is requested but unavailable (missing keys, API failure), analysis continues normally with a warning.

Privacy

  • The AI engine receives aggregated metrics only - never raw source code, full diffs, or file contents.
  • All analysis runs locally via Git commands against your repository.
  • No data is sent to external services unless AI engines are explicitly enabled.

License

MIT


  Files folder image Files (8)  
File Role Description
Files folder imageconfig (1 file)
Files folder imagesrc (2 files)
Files folder imagetests (2 files)
Accessible without login Plain text file composer.json Data Auxiliary data
Accessible without login Plain text file phpunit.xml Data Auxiliary data
Accessible without login Plain text file README.md Doc. Documentation

  Files folder image Files (8)  /  config  
File Role Description
  Accessible without login Plain text file codemetry.php Aux. Configuration script

  Files folder image Files (8)  /  src  
File Role Description
  Plain text file CodemetryAnalyzeCommand.php Class Class source
  Plain text file CodemetryServiceProvider.php Class Class source

  Files folder image Files (8)  /  tests  
File Role Description
  Plain text file ExampleTest.php Class Class source
  Accessible without login Plain text file Pest.php Aux. Configuration script

The PHP Classes site has supported package installation using the Composer tool since 2013, as you may verify by reading this instructions page.
Install with Composer Install with Composer
 Version Control Unique User Downloads  
 100%
Total:0
This week:0