PHPackages                             choerulumam/commitlint-php - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Validation &amp; Sanitization](/categories/validation)
4. /
5. choerulumam/commitlint-php

ActiveLibrary[Validation &amp; Sanitization](/categories/validation)

choerulumam/commitlint-php
==========================

A powerful Git hooks and commit message linting tool for PHP projects - PHP 7.3+ compatible

v1.1.0(6mo ago)111MITPHPPHP &gt;=7.3CI passing

Since Nov 14Pushed 6mo agoCompare

[ Source](https://github.com/chumam2050/commitlint-php)[ Packagist](https://packagist.org/packages/choerulumam/commitlint-php)[ RSS](/packages/choerulumam-commitlint-php/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (2)Versions (3)Used By (0)

CommitLint PHP 🎯
================

[](#commitlint-php-)

A powerful Git hooks and commit message linting tool for PHP projects - combining the best of husky and commitlint in a native PHP implementation.

[![PHP Version](https://camo.githubusercontent.com/a85872f82ccf9c42273208a2193640ed116e39aa999c45b62826bd3c6bf02f75/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d253345253344372e332d626c75652e737667)](https://www.php.net/)[![License](https://camo.githubusercontent.com/8bb50fd2278f18fc326bf71f6e88ca8f884f72f179d3e555e20ed30157190d0d/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d677265656e2e737667)](LICENSE)[![Packagist Version](https://camo.githubusercontent.com/f40415b455f7501051dab8ea95b6daae6b4edcc6ff26338e862c804f81539843/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f63686f6572756c756d616d2f636f6d6d69746c696e742d706870)](https://packagist.org/packages/choerulumam/commitlint-php)[![Packagist Downloads](https://camo.githubusercontent.com/6a8d25a66d57db42e1aedbe6f3904ca5daeea8563a07247a360020a497d681e6/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f63686f6572756c756d616d2f636f6d6d69746c696e742d706870)](https://packagist.org/packages/choerulumam/commitlint-php)[![Tests](https://camo.githubusercontent.com/3ab4882a1b7d64e5eb5168ad0b0b9cdfd53f59f114ee5f727958504214a5789c/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f74657374732d70617373696e672d627269676874677265656e2e737667)](tests/)[![Coverage](https://camo.githubusercontent.com/b3545ae1bcdb4ea486f71f87b43001e82dd21933bc8035d44601706c851265da/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f636f7665726167652d3130302532352d627269676874677265656e2e737667)](tests/)

🚀 Features
----------

[](#-features)

- **🎯 Commit Message Validation** - Enforce conventional commit format with customizable rules
- **🪝 Git Hooks Management** - Easy installation and management of Git hooks
- **⚙️ Flexible Configuration** - Configure via `.commitlintrc.json` or `composer.json`
- **🔧 Developer Friendly** - Beautiful CLI output with helpful error messages
- **📦 Minimal Dependencies** - Only requires Symfony Console component
- **🧪 Fully Tested** - Comprehensive test suite with PHPUnit
- **🎨 PHP 7.3+ Compatible** - Works with PHP 7.3 through PHP 8.3
- **🔒 Security First** - Built-in security features and input validation

Requirements
------------

[](#requirements)

- PHP &gt;= 7.3
- Composer
- Git

📦 Installation
--------------

[](#-installation)

Install via Composer:

```
composer require --dev choerulumam/commitlint-php
```

🔧 Quick Start
-------------

[](#-quick-start)

### 1. Install Git Hooks

[](#1-install-git-hooks)

```
vendor/bin/commitlint install
```

### 2. Start Making Commits!

[](#2-start-making-commits)

```
# ✅ Valid commits
git commit -m "feat: add user authentication"
git commit -m "fix(auth): resolve login validation issue"
git commit -m "docs: update README with examples"

# ❌ Invalid commits (will be rejected)
git commit -m "added new feature"  # Missing type
git commit -m "FIX: something"     # Invalid type case
```

📋 Commands
----------

[](#-commands)

### Install Hooks

[](#install-hooks)

Install Git hooks and create default configuration:

```
vendor/bin/commitlint install [options]
```

**Options:**

- `--force, -f` - Force installation even if hooks already exist
- `--skip-config` - Skip creating default configuration file

### Validate Commit Message

[](#validate-commit-message)

Validate commit messages against your configuration:

```
# Validate current commit message (from .git/COMMIT_EDITMSG)
vendor/bin/commitlint validate

# Validate specific message
vendor/bin/commitlint validate "feat: add new feature"

# Validate from file
vendor/bin/commitlint validate --file=commit.txt

# Quiet mode (exit code only)
vendor/bin/commitlint validate --quiet
```

**Options:**

- `--file, -f` - Read commit message from specific file
- `--quiet, -q` - Suppress output (exit code only)

### Show Status

[](#show-status)

Display installed hooks and configuration:

```
vendor/bin/commitlint status
```

### Uninstall

[](#uninstall)

Remove all installed Git hooks:

```
vendor/bin/commitlint uninstall [--force]
```

⚙️ Configuration
----------------

[](#️-configuration)

CommitLint PHP can be configured via `.commitlintrc.json` file or within your `composer.json`. The tool automatically merges your custom configuration with sensible defaults.

### Configuration File Priority

[](#configuration-file-priority)

1. `.commitlintrc.json` in your project root
2. `extra.commitlint-php` in `composer.json`
3. Default configuration

### Complete Configuration Reference

[](#complete-configuration-reference)

```
{
  "rules": {
    "type": {
      "required": true,
      "allowed": ["feat", "fix", "docs", "style", "refactor", "perf", "test", "chore", "ci", "build", "revert"]
    },
    "scope": {
      "required": false,
      "allowed": []
    },
    "subject": {
      "min_length": 1,
      "max_length": 100,
      "case": "any",
      "end_with_period": false
    },
    "body": {
      "max_line_length": 100,
      "leading_blank": true
    },
    "footer": {
      "leading_blank": true
    }
  },
  "hooks": {
    "commit-msg": true,
    "pre-commit": false,
    "pre-push": false
  }
}
```

### Configuration Options

[](#configuration-options)

#### Type Rules (`rules.type`)

[](#type-rules-rulestype)

- **`required`** (boolean, default: `true`) - Whether commit type is required
- **`allowed`** (array, default: see above) - Array of allowed commit types

#### Scope Rules (`rules.scope`)

[](#scope-rules-rulesscope)

- **`required`** (boolean, default: `false`) - Whether commit scope is required
- **`allowed`** (array, default: `[]`) - Array of allowed scopes (empty = any scope allowed)

#### Subject Rules (`rules.subject`)

[](#subject-rules-rulessubject)

- **`min_length`** (int, default: `1`) - Minimum subject length
- **`max_length`** (int, default: `100`) - Maximum subject length
- **`case`** (string, default: `"any"`) - Case requirement: `"lower"`, `"upper"`, or `"any"`
- **`end_with_period`** (boolean, default: `false`) - Whether subject must end with period

#### Body Rules (`rules.body`)

[](#body-rules-rulesbody)

- **`max_line_length`** (int, default: `100`) - Maximum line length for body (0 = no limit)
- **`leading_blank`** (boolean, default: `true`) - Require blank line between subject and body

#### Footer Rules (`rules.footer`)

[](#footer-rules-rulesfooter)

- **`leading_blank`** (boolean, default: `true`) - Require blank line between body and footer

#### Hook Configuration (`hooks`)

[](#hook-configuration-hooks)

Control which Git hooks are installed:

```
{
  "hooks": {
    "commit-msg": true,    // Validate commit messages
    "pre-commit": false,   // Run before commits
    "pre-push": false      // Run before pushes
  }
}
```

📖 Example Configurations
------------------------

[](#-example-configurations)

### Minimal Configuration

[](#minimal-configuration)

```
{
  "rules": {
    "type": {
      "allowed": ["feat", "fix", "docs", "chore"]
    },
    "subject": {
      "max_length": 50
    }
  }
}
```

### Strict Configuration

[](#strict-configuration)

```
{
  "rules": {
    "type": {
      "required": true,
      "allowed": ["feat", "fix", "docs", "test", "refactor", "chore"]
    },
    "scope": {
      "required": true,
      "allowed": ["auth", "api", "ui", "db", "config", "test", "docs"]
    },
    "subject": {
      "min_length": 10,
      "max_length": 50,
      "case": "lower",
      "end_with_period": false
    }
  }
}
```

### Configuration in `composer.json`

[](#configuration-in-composerjson)

```
{
  "extra": {
    "commitlint-php": {
      "rules": {
        "type": {
          "allowed": ["feat", "fix", "docs", "test", "chore"]
        }
      }
    }
  }
}
```

📝 Commit Message Format
-----------------------

[](#-commit-message-format)

This package enforces the [Conventional Commits](https://conventionalcommits.org/) specification:

```
[optional scope]:

[optional body]

[optional footer(s)]

```

### Examples

[](#examples)

```
# Simple commit
feat: add user registration

# With scope
feat(auth): add JWT token validation

# With body and footer
feat(api): add user endpoints

Add comprehensive user management endpoints including:
- GET /api/users
- POST /api/users
- PUT /api/users/{id}
- DELETE /api/users/{id}

Closes #123

# Breaking change
feat(api)!: redesign user authentication

BREAKING CHANGE: The authentication API has been completely redesigned.
All existing tokens will be invalidated.
```

### Default Commit Types

[](#default-commit-types)

- `feat` - New features
- `fix` - Bug fixes
- `docs` - Documentation changes
- `style` - Code style changes (formatting, etc)
- `refactor` - Code refactoring
- `perf` - Performance improvements
- `test` - Adding or updating tests
- `chore` - Maintenance tasks
- `ci` - CI/CD changes
- `build` - Build system changes
- `revert` - Reverting previous commits

### Special Commit Types (Auto-Skip Validation)

[](#special-commit-types-auto-skip-validation)

The following commit types automatically skip validation:

- Merge commits - `Merge branch "feature" into main`
- Revert commits - `Revert "feat: add user authentication"`
- Initial commits - `Initial commit`
- Fixup commits - `fixup! feat: add user authentication`

🛠️ Development
--------------

[](#️-development)

### Running Tests

[](#running-tests)

```
# Run all tests
composer test

# With coverage
composer test:coverage
```

🤝 Contributing
--------------

[](#-contributing)

Contributions are welcome! Please read our [Contributing Guide](CONTRIBUTING.md) for details.

📄 License
---------

[](#-license)

This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.

🙏 Acknowledgments
-----------------

[](#-acknowledgments)

- Inspired by [husky](https://github.com/typicode/husky) and [commitlint](https://github.com/conventional-changelog/commitlint)
- Inspired by [dev-kraken/php-commitlint](https://github.com/dev-kraken/php-commitlint)
- Built with [Symfony Console](https://symfony.com/doc/current/components/console.html)

Author
------

[](#author)

**chumam2050** -

###  Health Score

29

—

LowBetter than 59% of packages

Maintenance68

Regular maintenance activity

Popularity7

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity31

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~0 days

Total

2

Last Release

185d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/6f809025fdac010044041b78040b165fe17d05998e3cccc480f2606fc14c4439?d=identicon)[chumam2050](/maintainers/chumam2050)

---

Top Contributors

[![chumam2050](https://avatars.githubusercontent.com/u/200531105?v=4)](https://github.com/chumam2050 "chumam2050 (8 commits)")

---

Tags

validationgitcommitconventional-commitsgit-hookscommitlint

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/choerulumam-commitlint-php/health.svg)

```
[![Health](https://phpackages.com/badges/choerulumam-commitlint-php/health.svg)](https://phpackages.com/packages/choerulumam-commitlint-php)
```

###  Alternatives

[composer/semver

Version comparison library that offers utilities, version constraint parsing and validation.

3.3k489.6M672](/packages/composer-semver)[giggsey/libphonenumber-for-php

A library for parsing, formatting, storing and validating international phone numbers, a PHP Port of Google's libphonenumber.

5.0k148.7M416](/packages/giggsey-libphonenumber-for-php)[respect/validation

The most awesome validation engine ever created for PHP

5.9k37.4M383](/packages/respect-validation)[propaganistas/laravel-phone

Adds phone number functionality to Laravel based on Google's libphonenumber API.

3.0k35.7M107](/packages/propaganistas-laravel-phone)[ramsey/conventional-commits

A PHP library for creating and validating commit messages according to the Conventional Commits specification. Includes a CaptainHook action!

1931.2M122](/packages/ramsey-conventional-commits)[opis/json-schema

Json Schema Validator for PHP

64736.9M186](/packages/opis-json-schema)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
