|
| 1 | +# Contributing to the PHP Documentation |
| 2 | + |
| 3 | +You can easily contribute to the PHP documentation |
| 4 | +by either [reporting a bug](#report-a-bug) |
| 5 | +or by fixing one by [submitting a pull request](#submit-a-pull-request). |
| 6 | +As all the repositories are hosted on GitHub, |
| 7 | +you will need a GitHub account to do either of these. |
| 8 | + |
| 9 | +## Report a Bug |
| 10 | + |
| 11 | +If you have found a bug on any of the PHP documentation pages, |
| 12 | +you can file a bug report by doing the following: |
| 13 | + |
| 14 | +- click the "Report a Bug" link in the "Improve This Page" section |
| 15 | + on the bottom of the page |
| 16 | +- log into GitHub |
| 17 | +- add a short description of the bug in the title textbox |
| 18 | +- add all necessary details to the description textarea |
| 19 | +- click the "Submit new issue" button to file your bug report |
| 20 | + |
| 21 | +## Submit a Pull Request |
| 22 | + |
| 23 | +There are two ways to make changes to the documentation: |
| 24 | +- make [minor changes](#minor-changes) by editing files on GitHub |
| 25 | +- make [more complex changes](#more-complex-changes--building-the-php-documentation) |
| 26 | + and validate/build the documentation locally on your computer |
| 27 | + |
| 28 | +## Minor changes |
| 29 | + |
| 30 | +To make trivial changes (typos, shorter wording changes or adding/removing short segments) |
| 31 | +all one needs is a web-browser and a GitHub account and doing the following: |
| 32 | + |
| 33 | +- click the "Submit a Pull Request" link in the "Improve This Page" section |
| 34 | + on the bottom of the documentation page |
| 35 | +- log into GitHub |
| 36 | +- fork the repository (if you have not forked it already) |
| 37 | +- make changes |
| 38 | +- click the "Commit changes" button |
| 39 | +- add a commit message (short description of the change) into the "Commit message" textbox |
| 40 | +- write a longer description in the "Extended description" textarea, if needed |
| 41 | +- click the "Propose changes" button |
| 42 | +- review your changes and click "Create pull request" button |
| 43 | + |
| 44 | +The repository will run a few basic checks on the changes |
| 45 | +(e.g. whether the XML markup is valid, whether trailing whitespaces are stripped, etc.) |
| 46 | +and your PR is ready to be discussed with and merged by the maintainers. |
| 47 | + |
| 48 | +## More Complex Changes / Building the PHP documentation |
| 49 | + |
| 50 | +To build and view the documentation after making more extensive changes |
| 51 | +(e.g. adding entire sections or files), you will need to |
| 52 | +[clone some of the tooling](#set-up-a-development-environment) |
| 53 | +(doc-base, phd and possibly web-php) |
| 54 | +in addition to the language repository you want to |
| 55 | +[make the changes](#make-changes-to-the-documentation) to. |
| 56 | +You need to [validate the changes](#validate-the-documentation) |
| 57 | +and you can (but do not have to) [render the documentation](#render-the-documentation) |
| 58 | +before you [open a PR](#commit-changes-and-open-a-pr). |
| 59 | + |
| 60 | +If you'd like to know more about what each repository is |
| 61 | +and/or how PHP's documentation is built please refer to |
| 62 | +this [overview](https://github.com/php/doc-base/OVERVIEW.md). |
| 63 | + |
| 64 | +### Requirements |
| 65 | + |
| 66 | +Following this guide to make changes to and build the documentation has the following dependencies: |
| 67 | +- PHP 8.0+ with the DOM, libXML2, XMLReader and SQLite3 extensions |
| 68 | +- Git |
| 69 | +- an IDE or a text editor |
| 70 | + |
| 71 | +### Set up a development environment |
| 72 | + |
| 73 | +#### Basic setup |
| 74 | + |
| 75 | +To start working on the English documentation, you need to fork it on Github |
| 76 | +and clone it, doc-base (for validating the XML files) and PhD (for rendering the files). |
| 77 | + |
| 78 | +```shell |
| 79 | +git clone https://github.com/<your_github_username>/<your_fork> en |
| 80 | +git clone https://github.com/php/doc-base |
| 81 | +git clone https://github.com/php/phd |
| 82 | +cd en |
| 83 | +git remote add upstream https://github.com/php/doc-en |
| 84 | +``` |
| 85 | +where `<your_github_username>` and `<your_fork>` needs to be replaced by |
| 86 | +your GitHub username and the name of your for of the English documentation respectively. |
| 87 | +Please note that the English documentation has to be cloned into the `en` directory. |
| 88 | + |
| 89 | +To clone any of the translations, replace `doc-en en` at the end of the first line |
| 90 | +with the translation you would like to clone |
| 91 | +(e.g. `doc-pt_br` for the Brazilian documentation). |
| 92 | +As an example, the following shows how to set up the Brazilian documentation: |
| 93 | + |
| 94 | +```shell |
| 95 | +git clone https://github.com/<your_github_username>/doc-pt_br |
| 96 | +git clone https://github.com/php/doc-base |
| 97 | +git clone https://github.com/php/phd |
| 98 | +cd doc-pt_br |
| 99 | +git remote add upstream https://github.com/php/doc-pt_br |
| 100 | +``` |
| 101 | +where `<your_github_username>` needs to be replaced by your GitHub username. |
| 102 | + |
| 103 | +<details> |
| 104 | + <summary>List of languages/repositories</summary> |
| 105 | + |
| 106 | + - [Brazilian Portugues](https://github.com/php/doc-pt_br) (doc-pt_br) |
| 107 | + - [Chinese(Simplified)](https://github.com/php/doc-zh) (doc-zh) |
| 108 | + - [English](https://github.com/php/doc-en) (doc-en) |
| 109 | + - [French](https://github.com/php/doc-fr) (doc-fr) |
| 110 | + - [German](https://github.com/php/doc-de) (doc-de) |
| 111 | + - [Italian](https://github.com/php/doc-it) (doc-it) |
| 112 | + - [Japanese](https://github.com/php/doc-ja) (doc-ja) |
| 113 | + - [Polish](https://github.com/php/doc-pl) (doc-pl) |
| 114 | + - [Romanian](https://github.com/php/doc-ro) (doc-ro) |
| 115 | + - [Russian](https://github.com/php/doc-ru) (doc-ru) |
| 116 | + - [Spanish](https://github.com/php/doc-es) (doc-es) |
| 117 | + - [Turkish](https://github.com/php/doc-tr) (doc-tr) |
| 118 | + - [Ukrainian](https://github.com/php/doc-uk) (doc-uk) |
| 119 | +</details> |
| 120 | + |
| 121 | +#### Setting up a local mirror |
| 122 | + |
| 123 | +If you would like to setup a local mirror of the documentation |
| 124 | +or you would just like to see how your changes will look like online: |
| 125 | + |
| 126 | +```shell |
| 127 | +git clone https://github.com/php/web-php |
| 128 | +cd web-php/manual |
| 129 | +rm -rf en |
| 130 | +ln -s ../../output/php-web en |
| 131 | +``` |
| 132 | + |
| 133 | +where `../../output/php-web` is the directory the PhD generated .php files are saved at, |
| 134 | +relative to the `web-php/manual` directory. |
| 135 | + |
| 136 | +On Windows: |
| 137 | + |
| 138 | +```shell |
| 139 | +git clone https://github.com/php/web-php |
| 140 | +cd \your\path\to\web-php\manual\ |
| 141 | +rmdir /S en |
| 142 | +mklink /D en \your\path\to\output\web-php |
| 143 | +``` |
| 144 | + |
| 145 | +where `\your\path\to\output\web-php` is the directory the PhD generated .php files are saved at, |
| 146 | +relative to the `\your\path\to\web-php\manual\` directory. |
| 147 | + |
| 148 | +#### Using your local mirror |
| 149 | + |
| 150 | +You can view the documentation by using any web server |
| 151 | +but one of the simplest ways is to use PHP's built-in web server: |
| 152 | + |
| 153 | +```shell |
| 154 | +cd web-php |
| 155 | +php -S localhost:8080 .router.php |
| 156 | +``` |
| 157 | + |
| 158 | +where `web-php` is the directory web-php has been cloned into. |
| 159 | + |
| 160 | +The manual is now available from http://localhost:8080/manual/en/ in your browser. |
| 161 | + |
| 162 | +### Make changes to the documentation |
| 163 | + |
| 164 | +Make your changes keeping in mind the [style guidelines](http://doc.php.net/tutorial/style.php). |
| 165 | + |
| 166 | +### Validate the documentation |
| 167 | + |
| 168 | +To validate the English documentation (located in the directory `en`), run |
| 169 | +```shell |
| 170 | +php doc-base/configure.php |
| 171 | +``` |
| 172 | + |
| 173 | +To validate any other documentation, run |
| 174 | +```shell |
| 175 | +php doc-base/configure.php --with-lang=doc-lang |
| 176 | +``` |
| 177 | +where `doc-lang` is the name of your language's repository |
| 178 | +and the corresponding directory (eg. `doc-de` for German). |
| 179 | + |
| 180 | +*Please note that all validation errors have to be corrected |
| 181 | +before opening a PR.* |
| 182 | + |
| 183 | +### Render the documentation |
| 184 | + |
| 185 | +To render the documentation in xhtml format (can be viewed without a web server), run |
| 186 | +```shell |
| 187 | +php phd/render.php --docbook doc-base/.manual.xml --package PHP --format xhtml |
| 188 | +``` |
| 189 | + |
| 190 | +To render the documentation in php format (needs a web server and web-php), run |
| 191 | +```shell |
| 192 | +php phd/render.php --docbook doc-base/.manual.xml --package PHP --format php |
| 193 | +``` |
| 194 | + |
| 195 | +### Commit changes and open a PR |
| 196 | + |
| 197 | +- commit your changes |
| 198 | +- push to your fork |
| 199 | +- open a PR in the appropriate language repository |
| 200 | + |
| 201 | +Once you open a PR, the documentation repository will run a few basic checks on the changes |
| 202 | +(e.g. whether the XML markup is valid, whether trailing whitespaces are stripped, etc.) |
| 203 | +and your PR is ready to be discussed with and merged by the maintainers. |
| 204 | + |
| 205 | +## Additional information |
| 206 | + |
| 207 | +For additional information on contributing to the documentation refer to: |
| 208 | + |
| 209 | +- the [Adding new documentation](http://doc.php.net/tutorial/editing.php) |
| 210 | + section of the "Editing manual sources" page |
| 211 | +- the [Files structure](http://doc.php.net/tutorial/structure.php) |
| 212 | + section of the "Manual sources structure" page |
| 213 | +- the [Translating documentation](http://doc.php.net/tutorial/translating.php) page |
| 214 | +- the [Style guidelines](http://doc.php.net/tutorial/style.php) page |
| 215 | +- the [FAQ](http://doc.php.net/tutorial/faq.php) page |
| 216 | +- the [Why we care about whitespace](http://doc.php.net/tutorial/whitespace.php) page |
| 217 | +- doc-base's [README](https://github.com/php/doc-base/blob/master/README.md) |
0 commit comments