Download the PHP package dev-kraken/php-commitlint without Composer
On this page you can find all versions of the php package dev-kraken/php-commitlint. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download dev-kraken/php-commitlint
More information about dev-kraken/php-commitlint
Files in dev-kraken/php-commitlint
Package php-commitlint
Short Description A powerful Git hooks and commit message linting tool for PHP projects - combining the best of husky and commitlint in a native PHP implementation
License MIT
Homepage https://github.com/dev-kraken/php-commitlint
Informations about the package php-commitlint
PHP CommitLint ๐ฏ
A powerful Git hooks and commit message linting tool for PHP projects - combining the best of husky and commitlint in a native PHP implementation.
๐ 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.jsonorcomposer.json - ๐ง Developer Friendly - Beautiful CLI output with helpful error messages
- ๐ฆ Zero Dependencies - Pure PHP implementation using only Symfony Console
- ๐งช Fully Tested - Comprehensive test suite with Pest
- ๐จ Modern PHP - PHP 8.3+ with strict types and modern syntax
- ๐ Security First - Built-in security features and input validation
- ๐๏ธ Custom Hooks - Add your own git hooks with custom commands
๐ฆ Installation
Install via Composer:
๐ง Quick Start
1. Install Git Hooks
2. Start Making Commits!
๐ Commands
Install Hooks
Install Git hooks and create default configuration:
Options:
--force, -f- Force installation even if hooks already exist--skip-config- Skip creating default configuration file
Validate Commit Message
Validate commit messages against your configuration:
Options:
--file, -f- Read commit message from specific file--quiet, -q- Suppress output (exit code only)--verbose-errors- Show detailed error information
Manage Custom Hooks
Add and manage custom Git hooks:
Uninstall
Remove all installed Git hooks:
โ๏ธ Configuration
PHP CommitLint 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
.commitlintrc.jsonin your project rootextra.php-commitlintincomposer.json- Default configuration
Complete Configuration Reference
Configuration Options Explained
General Settings
auto_install(boolean, default:false) - Automatically install hooks when composer install/update runs
Rules Configuration
Type Rules (rules.type)
required(boolean, default:true) - Whether commit type is requiredallowed(array, default: see above) - Array of allowed commit types
Scope Rules (rules.scope)
required(boolean, default:false) - Whether commit scope is requiredallowed(array, default:[]) - Array of allowed scopes (empty = any scope allowed)
Subject Rules (rules.subject)
min_length(int, default:1) - Minimum subject lengthmax_length(int, default:100) - Maximum subject lengthcase(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)
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)
leading_blank(boolean, default:true) - Require blank line between body and footer
Pattern Validation (patterns)
Define custom regex patterns for additional validation:
Hook Configuration (hooks)
Control which Git hooks are installed:
Team-Wide Pre-Commit Commands (pre_commit_commands)
Configure commands that run automatically for all team members during pre-commit:
Benefits:
- Automatic for all team members - No manual hook setup required
- Consistent quality checks - Same commands run for everyone
- Version controlled - Configuration is committed and shared
- Easy maintenance - Update once, applies to all developers
When any team member runs composer install (with auto_install: true), these commands automatically run before every commit.
Format Configuration (format)
type(boolean) - Require commit typescope(string) - Scope requirement: "required", "optional", "forbidden"description(boolean) - Require commit descriptionbody(string) - Body requirement: "required", "optional", "forbidden"footer(string) - Footer requirement: "required", "optional", "forbidden"
๐ช Windows Support
PHP CommitLint provides full Windows compatibility with automatic detection and setup:
Automatic Windows Support
- PHP Detection: Automatically finds PHP in XAMPP, WAMP, Laragon, or standard installations
- Path Handling: Converts Windows paths for Git Bash compatibility
- Batch Wrapper: Includes
php-commitlint.batfor Windows CLI - Hook Compatibility: Git hooks work seamlessly in Git Bash, PowerShell, and Command Prompt
Windows Installation
Windows Troubleshooting
If you see "PHP CommitLint not found":
- Ensure PHP is in your PATH:
php --version - Try using the batch file:
vendor\bin\php-commitlint.bat install - Check Git Bash compatibility: Use
/c/path/to/phpformat
Common Windows Scenarios:
- XAMPP:
C:\xampp\php\php.exe(automatically detected) - WAMP:
C:\wamp\bin\php\php8.3\php.exe(automatically detected) - Laragon:
C:\laragon\bin\php\php8.3\php.exe(automatically detected) - Standalone:
C:\php\php.exe(automatically detected)
๐ Example Configurations
Minimal Configuration (examples/commitlintrc.minimal.json)
Strict Configuration (examples/commitlintrc.strict.json)
Configuration in composer.json
You can also configure PHP CommitLint in your composer.json:
๐ Commit Message Format
This package enforces the Conventional Commits specification:
Examples
Default Commit Types
feat- New featuresfix- Bug fixesdocs- Documentation changesstyle- Code style changes (formatting, etc)refactor- Code refactoringperf- Performance improvementstest- Adding or updating testschore- Maintenance tasksci- CI/CD changesbuild- Build system changesrevert- Reverting previous commits
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 & Testing
Running Tests
Code Quality
Available Make Commands
๐ Integration with CI/CD
GitHub Actions
GitLab CI
๐จ Error Codes
PHP CommitLint uses specific exit codes for different error conditions:
0- Success1- Validation failed2- Configuration error3- File system error4- Invalid argument5- Runtime error6- Permission denied7- Not a Git repository
๐ Security Features
- Input validation for all commit message processing
- Safe command execution using Symfony Process component
- Configuration validation to prevent malicious configs
- Path traversal protection in file operations
- File size limits (100KB max for config files)
- No eval() or dynamic code execution
- Command validation prevents dangerous operations in custom hooks
๐ค Contributing
We welcome contributions! Please see our Contributing Guide for details.
Quick Start for Contributors
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Make your changes and add tests
- Run the test suite (
composer test) - Check code style (
composer cs:check) - Run static analysis (
composer analyse) - Commit your changes (
git commit -m "feat: add amazing feature") - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
๐ License
This project is licensed under the MIT License - see the LICENSE file for details.
๐ Acknowledgments
- Inspired by husky and commitlint
- Built with Symfony Console
- Tested with Pest
๐ Documentation
- ๐ API Documentation - Detailed API reference for developers
- โ FAQ - Frequently asked questions and troubleshooting
- ๐ค Contributing Guide - How to contribute to the project
- ๐ Changelog - Release notes and version history
- ๐ Security Policy - Security guidelines and reporting
๐ Support
- ๐ง Email: [email protected]
- ๐ Issues: GitHub Issues
- ๐ฌ Discussions: GitHub Discussions
- โ FAQ: Frequently Asked Questions
Made with โค๏ธ by DevKraken
All versions of php-commitlint with dependencies
psr/log Version ^3.0
symfony/console Version ^6.4|^7.0
symfony/process Version ^6.4|^7.0