Want to start a new PHP project? Perhaps yet another library you are creating? Tired of doing the same lame groundwork for the 5th time this month? Want to start a code kata and not lose time on generic setup work? I got just the project for you!
Edit: there now is a dedicated PHP library template better suited for library creation!
I’ve created a PHP project template that you can fork or copy to get started quickly. It contains setup for testing, lining and CI and no actual PHP code. A detailed list of the project templates contents:
- Ready-to-go PHPUnit (configuration and working bootstrap)
- Ready-to-go PHPCS
- Docker environment with PHP 7.2 and Composer (so you do not need to have PHP or Composer installed!)
- Tests and style checks runnable in the Docker environment with simple
make
commands - TravisCI ready
- Code coverage creation on TravisCI and uploading to ScrutinizerCI (optional)
- Coverage tag validation
- Stub production and test classes for ultra-quick start (ideal when doing a kata)
- COPYING and
.gitignore
files - README with instructions of how to run the tests
Getting started
- Copy the code or fork the repository
- If you do not want to use the MediaWiki coding style, remove
mediawiki/mediawiki-codesniffer
fromcomposer.json
- If you want to support older PHP versions, update
composer.json
and remove new PHP features from the stub PHP files - If the code is not a kata or quick experiment, update the PHP namespaces and the README
- Start writing code!
- If you want TravisCI and/or ScrutinizerCI integration you will need to log in to their respective websites
- Optionally update the README
You can find the project template on GitHub.
Special thanks to weise, gbirke and KaiNissen for their contributions to the projects this template was extracted from.
1 thought on “PHP project template”