kununu / code-tools
Code Tools
Installs: 54
Dependents: 4
Suggesters: 0
Security: 0
Stars: 0
Watchers: 3
Forks: 0
Open Issues: 1
Type:composer-plugin
pkg:composer/kununu/code-tools
Requires
- php: >=8.3
- composer-plugin-api: ^2.0
- composer/composer: ^2.8
- friendsofphp/php-cs-fixer: ^3.75
- phpat/phpat: ^0.11.4
- phpstan/phpstan: ^2.1
- rector/rector: ^2.0
- squizlabs/php_codesniffer: ^3.10
- symfony/yaml: ^6.4
Requires (Dev)
- phpunit/phpunit: ^11.5
README
code-tools
- This repository contains code tools you can use in your project.
- It is a collection of tools and scripts that help us to maintain our codebase.
Tools
.editorconfig
- EditorConfig helps maintain consistent coding styles for multiple developers working on the same project across various editors and IDEs. The EditorConfig project consists of a file format for defining coding styles and a collection of text editor plugins that enable editors to read the file format and adhere to defined styles. EditorConfig files are easily readable and they work nicely with version control systems.
- Learn more about
.editorconfigat official page here.
PHP-CS-Fixer
- This project uses PHP-CS-Fixer to automatically format and fix PHP code according to defined coding standards. It helps maintain clean, consistent, and readable code across the codebase.
PHP_CodeSniffer
- PHP_CodeSniffer is a set of two PHP scripts; the main
phpcsscript that tokenizes PHP, JavaScript and CSS files to detect violations of a defined coding standard, and a secondphpcbfscript to automatically correct coding standard violations. PHP_CodeSniffer is an essential development tool that ensures your code remains clean and consistent. - Though the usage of this tool is not mandatory, it is highly recommended to use it to ensure the quality of the codebase.
- Learn more about PHP_CodeSniffer at official page here.
Rector
- Rector is a tool that automatically upgrades and refactors your PHP code. It is a tool that helps you to keep your code up-to-date and clean.
- Learn more about Rector at official page here.
bin/code-tools
- Though each tool can be used "out-of-the-box", this is a helper script that allows you to copy configuration files of each, or all, tools to your project so you can customize them.
bin/php-in-k8s
- This is a helper script that allows you to run PHP commands inside a local Kubernetes pod without having to connect to it via a terminal manually.
Architecture Sniffer & PHPAT
-
Architecture Sniffer enforces architectural and dependency rules in your PHP codebase, helping you maintain a clean and consistent architecture.
-
It is powered by PHPAT, a static analysis tool for PHP architecture testing.
-
Architecture Sniffer uses a YAML configuration file (
architecture.yaml) where you define your architectural groups and their allowed dependencies. Each group is a key under thearchitectureroot, e.g.:architecture: $controllers: includes: - "App\\Controller\\*Controller" depends_on: - "$services" $services: includes: - "App\\Service\\*Service"
-
To use Architecture Sniffer with PHPStan, add the extension to your
phpstan.neon:includes: - vendor/carlosas/phpat/extension.neon services: - class: PHPAT\PHPStan\PHPStanExtension tags: [phpstan.extension]
-
For more details and advanced configuration, see Kununu/ArchitectureSniffer/README.md.
Require Library as a dev dependency
You can use this library by issuing the following command:
composer require --dev kununu/code-tools --no-plugins
- The
--no-pluginsis used to avoid the composer plugins to be executed and prevent generating unwanted configuration files, specially in projects withsymfony/flexinstalled.
Usage
- .editorconfig instructions.
- PHP-CS-Fixer instructions.
- PHP_CodeSniffer instructions.
- Rector instructions.
- bin/code-tools instructions.
- bin/php-in-k8s instructions.
- Architecture Sniffer & PHPAT instructions.
