186d9143fSBen# How to contribute 286d9143fSBen 386d9143fSBenThanks for taking the time to contribute! 486d9143fSBen 586d9143fSBenThe following is a set of guidelines for contributing to Webtrees. These are mostly guidelines, not rules. 686d9143fSBenUse your best judgment, and feel free to propose changes to this document in a pull request. 786d9143fSBen 886d9143fSBen## How to submit a patch or feature 986d9143fSBen 1086d9143fSBenIf you want to submit a patch or feature, please create a pull request on Github. There are different branches for different versions of webtrees: 1186d9143fSBen 1286d9143fSBen* For webtrees 2.0, use the `master` branch 1386d9143fSBen* For the latest webtrees 1.7.*, use the `1.7` branch 1486d9143fSBen 1586d9143fSBenBefore submitting a pull request make sure you have [tested the code](#how-to-test) 1686d9143fSBenand [followed the coding conventions](#coding-conventions). 1786d9143fSBen 18*d3fe06a8SGreg RoachPlease read more about [setting up your environment](#how-to-setup-a-development-environment) for development. 1986d9143fSBen 2086d9143fSBen## How to start 2186d9143fSBen 2286d9143fSBenYou can start contributing by 2386d9143fSBen 2486d9143fSBen* submitting patches or features 2586d9143fSBen* writing tests to [increase the test coverage](https://coveralls.io/github/fisharebest/webtrees?branch=master) 2686d9143fSBen* creating or updating [translations](#translations) 2786d9143fSBen* Join our slack. The invitation link will be updated on this line. 2886d9143fSBen* Help us maintaining our github page from the repository [webtrees.github.io](https://github.com/webtrees/webtrees.github.io). 2986d9143fSBen 3086d9143fSBen## How to setup a development environment 3186d9143fSBen 3286d9143fSBenYou will need three tools, in addition to the requirements of a live installation. 3386d9143fSBen 3486d9143fSBen* `git` - to fetch the latest development code, merge changes, create pull requests, etc. 3586d9143fSBen* [`composer`](https://getcomposer.org) - to install PHP dependencies, build releases, and run tests. 3686d9143fSBen* [`npm`](https://nodejs.org/en/download/package-manager) - to install CSS/JS dependencies and create portable/minified `.css` / `.js` files. 3786d9143fSBen 3886d9143fSBenYou do not need to understand the details of `composer` and `npm`. You just need to be able to type a few commands at a console. 3986d9143fSBen 4086d9143fSBenIf you are going to submit your work to the project, you will need a basic understanding of `git`. The workflow for using git is covered below in the section on "Pull Requests". 4186d9143fSBen 4286d9143fSBen### GIT 4386d9143fSBen 4486d9143fSBenThe project has been running for many years, and has a lot of history. 4586d9143fSBenThis means that the full repository is over 600MB. 4686d9143fSBen 4786d9143fSBenIf you are only interested in the latest version of the code, you can use a 4886d9143fSBen"shallow clone", which is about 30MB. 4986d9143fSBen 5086d9143fSBenUse `git clone --depth 1 https://github.com/fisharebest/webtrees`. 5186d9143fSBen 5286d9143fSBen### Composer 5386d9143fSBen 5486d9143fSBenThe instructions below assume you have created an alias/shortcut for `composer`. 5586d9143fSBenIf not, you'll need to replace `composer` with `php /path/to/your/copy/of/composer.phar`. 5686d9143fSBen 5786d9143fSBen* You would usually run `composer install` before starting any develoment. This loads all the development tools, including the PHP debug bar, the build scripts, the analysis and testing tools. You would then run `composer install --no-dev` before committing any changes. 5886d9143fSBen 5986d9143fSBen* The PHP Debug Bar can set a large number of HTTP headers, and you may need to increase the size of buffers in your webserver configuration. There are some notes in the file `app/Http/Middleware/UseDebugbar.php`. 6086d9143fSBen 6186d9143fSBen* You can use a "pre-commit hook" to run checks on your code before you commit them to your local repository. To do this, rename the file `.git/hooks/pre-commit.sample` to `.git/hooks/pre-commit` and then add this line at the end of the file: `composer webtrees:pre-commit-hook`. 6286d9143fSBen 6386d9143fSBen### NPM 6486d9143fSBen 6586d9143fSBen* After modifying any CSS or JS files, you'll need to rebuild the files in `public/js` and `public/css`. You do this with the command `npm run production`. 6686d9143fSBen 6786d9143fSBen## Third-party libraries and compiled files in the source tree 6886d9143fSBen 6986d9143fSBenFor historic reasons, we include certain third-party libraries and compiled 7086d9143fSBenfiles in our source tree. This is usually considered to be bad practice. 7186d9143fSBenWe do it because we have a large number of testers and users who have become 7286d9143fSBenaccustomed to downloading the latest source code and running it without any build step. 7386d9143fSBen 7486d9143fSBenWe include the non-development PHP libraries from `/vendor`. 7586d9143fSBenThese are created using the command `composer install --no-dev`. 7686d9143fSBen 7786d9143fSBenWe include the compiled JS and CSS assets from `/public/{css,js}`). 7886d9143fSBenThese are created using the command `npm run production`. 7986d9143fSBen 8086d9143fSBen 8186d9143fSBen## Creating a pull request 8286d9143fSBen 8386d9143fSBen[TODO] 8486d9143fSBen 8586d9143fSBen 8686d9143fSBen 8786d9143fSBen1. Fork and clone the repository 8886d9143fSBen2. Run `composer install` to update the PHP dependencies. 8986d9143fSBen3. Run `npm install` to update the JS and HTML files. 9086d9143fSBen4. Run `php -S localhost:8080` and open your browser at [localhost:8080](http://localhost:8080) 9186d9143fSBen5. Go through the install process 9286d9143fSBen 9386d9143fSBen## How to test 9486d9143fSBen 9586d9143fSBenInstall PHPUnit by running `composer install` 9686d9143fSBen 9786d9143fSBenThen run the tests with `vendor/bin/phpunit` 9886d9143fSBen 9986d9143fSBen## Coding conventions 10086d9143fSBen 10186d9143fSBenYour code should follow the [PSR-12](https://www.php-fig.org/psr/psr-12/) Extended coding style guide. 10286d9143fSBen 10386d9143fSBenPlease do not contribute your IDE directories (e.g. `.idea` or `.vscode`). 10486d9143fSBen 10586d9143fSBen## Translations 10686d9143fSBen 10786d9143fSBenPlease refer to the guide from the [official wiki](https://wiki.webtrees.net/en/Category:Translation_Guidelines). 10886d9143fSBen 10986d9143fSBenThere is a [translators forum](http://webtrees.net/index.php/en/forum/8-translation) where you can discuss any issues relating to translation. 11086d9143fSBen 11186d9143fSBenUpdates to translations should be made at [translate.webtrees.net](https://translate.webtrees.net). 11286d9143fSBenChanges made there will be pushed to webtrees git repository periodically and will be available 11386d9143fSBenon the development version of webtrees. They will be included in the next release of webtrees. 11486d9143fSBen 115