A powerful PHP tool to improve and manage your code quality through various commands and checks.
- PSR-4 namespace checking and validation
- Autoloader optimization
- Code quality tools integration
- Code formatting
- Static analysis
First, add the repository to your composer.json:
{
"repositories": [
{
"type": "vcs",
"url": "https://github.com/aircury/code-manager"
}
]
}Then install the package as dev dependency:
composer require aircury/code-manager --devChecks and fixes code style issues.
bin/code-manager code:format [options] [--] [<files>...]This command:
- Validates code style compliance
- Automatically fixes code style issues
- Uses PHP CS Fixer rules
- Returns success (0) or failure (1) status code
Options:
--branchor-b- Run the formatter in your branch new files relative to the specified branch--read-onlyor-o- Run the formatter in read only mode, showing the diff if the files had been formatted and the applied rules
Arguments:
files- Specify files that you want to format (array)
Performs static analysis on your code.
bin/code-manager code:analyser [options] [--] [<files>...]This command:
- Runs PHPStan analysis
- Checks for potential bugs
- Validates type safety
- Returns success (0) or failure (1) status code
Options:
--branchor-b- Run the formatter in your branch new files relative to the specified branch--levelor-l- Specify level to run the analyser
Arguments:
files- Specify files that you want to format (array)
Checks if classes follow PSR-4 autoloading and namespace rules.
bin/code-manager namespace:checkThis command:
- Validates PSR-4 compliance
- Optimizes the autoloader
- Checks namespace rules
- Returns success (0) or failure (1) status code
Formats YAML files according to specified rules.
bin/code-manager yaml:format [options]This command:
- Automatically formats YAML files
- Maintains consistent indentation
- Optimizes YAML structure
Options:
--indentor-i- Number of spaces for indentation (default: 2)--inlineor-l- Level where to switch to inline YAML (default: 2)
The command will automatically detect and format all YAML files (.yaml or .yml) that have been changed in your current branch.