Thank you for your interest in contributing to the LCache project. LCache is used in multiple frameworks, including Drupal 8, Drupal 7 and WordPress; it is therefore very important that all changes made to the common library are well tested, and generic enough to work in multiple environments.
Here are some of the guidelines you should follow to make the most of your efforts:
Consolidation adheres to the PSR-2 Coding Style Guide for PHP code.
Every pull request is run through:
- phpcs -n --standard=PSR2 src
- phpunit
- Scrutinizer
It is easy to run the unit tests and code sniffer locally; just run:
- composer cs
To run the code beautifier, which will fix many of the problems reported by phpcs:
- composer cbf
These two commands (composer cs
and composer cbf
) are defined in the scripts
section of composer.json.
After submitting a pull request, please examine the Scrutinizer report. It is not required to fix all Scrutinizer issues; you may ignore recommendations that you disagree with. The spacing patches produced by Scrutinizer do not conform to PSR2 standards, and therefore should never be applied. DocBlock patches may be applied at your discression. Things that Scrutinizer identifies as a bug nearly always need to be addressed.
Pull requests must pass phpcs and phpunit in order to be merged; ideally, new functionality will also maintain full test coverage.
To run the phpunit tests prior to submitting a pull request, follow the instructions below.
-
Install packages:
On Fedora:
sudo dnf install -y php-cli composer php-phpunit-PHPUnit php-phpunit-DbUnit php-pecl-apcu php-pecl-xdebug php-opcache
On macOS:
brew install php70-xdebug brew install php70-opcache brew install php70-apcu
-
Enable APCu caching for the CLI, if necessary:
echo "apc.enable_cli=1" | sudo tee -a /etc/php.d/40-apcu.ini
Replace last argument with path to your php.ini. (
php -i | grep php.ini
). This setting may already be enabled on your system; to find out, run:php -i | grep -i enable_cli
You will see
apc.enable_cli => On => On
if it is enabled. -
From the project root directory:
composer install composer test
The LCache API documentation is built from PHP docblock comments using Sami, the Symfony API documentation generator. Documentation updates are built automatically on passing build on the master branch. If you would like to build the API documentation locally, run:
- composer sami-install
- composer api
The documentation site is currently a simple static html site built using GitHub Pages. To contribute to documentation, submit a PR on the gh-pages branch.