Download the PHP package uuf6429/elder-brother without Composer
On this page you can find all versions of the php package uuf6429/elder-brother. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download uuf6429/elder-brother
More information about uuf6429/elder-brother
Files in uuf6429/elder-brother
Package elder-brother
Short Description Set up and manage contribution policies for your PHP-based projects.
License MIT
Homepage https://github.com/uuf6429/elder-brother
Informations about the package elder-brother
Elder Brother
Elder Brother automatically regulates contributions before reaching your project.
Using events such as Git-hooks, one can ease development in various ways, such as:
- ensure code style conformity before committing changes
- run tools whose output should be a part of the commit
- performing roll-backs when checking-out old commits
- compiling sources or performing migrations when checking-out newer commits
This tools makes it easy to set up these tasks, as well as putting such policies under version control.
Table Of Contents
- Elder Brother
- Table Of Contents
- Installation
- Usage
- Available Actions
- Execute Custom Code (ExecuteCode)
- Execute External Program (ExecuteProgram)
- Disallow Files (ForbiddenFiles)
- PHP Code Style Fixer (PhpCsFixer)
PHP Code Style Fixer (PhpCsFixerOld)- PHP Syntax Check (PhpLinter)
- Show Warning For Files (RiskyFiles)
- FAQ
Installation
-
Add the library to your project with Composer:
Notes:
- in this way, Elder Brother will only be installed during development (Composer should be run with
--no-dev
in production). scriptsdev
package will make installation work during development and not break during production.- you may still have to install additional packages (detailed below) to use some particular actions.
- in this way, Elder Brother will only be installed during development (Composer should be run with
-
Add the following entry to your
composer.json
: - Create a
.brother.php
config file (as described below) and add.brother.local.php
to your.gitignore
file (this allows for user-level config).
Usage
Elder Brother by default reads configuration from two files, .brother.php
and .brother.local.php
(which should be ignored by your VCS).
A typical configuration file will be structured like this:
Basically, the configuration is an array of actions grouped by event.
In the above example, PhpLinter
and PhpCsFixer
actions will check all files (GitChangeSet::getAddedCopiedModified()
) in the commit before it takes place (Event\Git::PRE_COMMIT
).
It is recommended that you give each action a defined numeric index, so that they can be easily overridden by user config.
Note that no matter how the items look like in the array, action execution starts from the smallest index.
Available Actions
Execute Custom Code (ExecuteCode)
Executes the passed callback, function or static method.
Execute External Program (ExecuteProgram)
Executes an external program.
Disallow Files (ForbiddenFiles)
Will stop process if $files
is not empty, for the reason specified in $reason
.
PHP Code Style Fixer (PhpCsFixer)
Runs all the provided files through PHP-CS-Fixer, fixing any code style issues.
PHP Code Style Fixer (PhpCsFixerOld)
Deprecated: Use PhpCsFixer class instead.
Runs all the provided files through PHP-CS-Fixer, fixing any code style issues.
PHP Syntax Check (PhpLinter)
Ensures that all the provided files are valid PHP files, terminating the process with an error and non-zero exit code, if not.
Show Warning For Files (RiskyFiles)
Will show a warning if $files
is not empty, for the reason specified in $reason
.
FAQ
What is the main motivation behind this tool?
Projects with a considerable amount of collaborators usually ends up with policies of what kind of patches are accepted. This is usually enforced through code-reviews (which can be very time-consuming), custom tools (difficult to set up) or shell scripts in pre-commit hooks (difficult to maintain and not really scalable).
The main idea here is to have a framework on the client side to enforce project contribution policies even before the source code reaches the main repository - saving developer time and maintenance costs.
Why in PHP?
Why not? There are two alternatives: shell scripts and other languages. Shell scripts have many disadvantages for this use - they're not cross-platform compatible, nor easily understandable. Other languages might be suitable, but it means requiring your collaborators to know them. We're basically using what's already available in the ecosystem.