First off, thanks for having the willingness to contribute, and for taking the time to read this document!
This project is the engine behind the bnetdocs.org website.
Day-to-day work happens on the develop branch, and releases are made by merging develop into the phoenix branch. Please open pull requests against develop.
Every push and pull request runs the ci-cd GitHub Actions workflow, which lints every PHP file and runs the PHPUnit tests on PHP 8.4 and 8.5, and runs PHPStan. Lint and tests also run on nightly builds of PHP 8.6 and 8.7 as an early warning; those jobs may fail without failing the run. Pushes to develop and phoenix are then deployed automatically:
| Branch | Deployed to |
|---|---|
| develop | dev.bnetdocs.org |
| phoenix | bnetdocs.org (production) |
All feature requests for the project must be vetted by one of the maintainers. The maintainer will decide whether or not a request is valid and will subsequently either approve or deny a request. If approved, someone will integrate the feature or enhancement into the project when possible and when time permits.
If an issue or bug is found with the project, do not hesitate to let the maintainers know. All bug reports are welcome and will be handled in a respectful manner.
When submitting an issue, make sure to include as much detail where possible, such as the following:
- A screenshot of the issue.
- Steps to reproduce the issue.
- How the issue was encountered.
- What the intention was and what was or was not expected to happen.
- Details about the environment:
- The operating system and its version number (e.g. Windows 11 Pro).
- The web browser and its version number, or its user agent (e.g. Firefox 140).
Giving the information above will help immensely when troubleshooting the issue, and could even lead directly to a code change in the best scenario.
The project is structured such that it can support tools, sample configurations, documentation, and of course the actual code, all in the same repository.
| Path | Description |
|---|---|
| /bin/ | Binaries, scripts, and utilities for working with this project. |
| /etc/ | Configuration files, samples, and Docker build files. |
| /lib/ | Vendor files from composer. |
| /src/ | The project source code. This is the web server's document root. |
| /tests/ | PHPUnit tests, mirroring the layout of /src/. |
| /tmp/ | An intentionally empty directory for use with scripts. |
Any file in the root of this repository is used by Git, GitHub, Docker, Composer, or otherwise serves a very specific purpose such as licensing and the read me.
- PHP 8.4 or newer. Production and CI run PHP 8.5.
- MariaDB 10.7 or newer.
- Nginx, as a FastCGI proxy to php-fpm.
- Composer.
- The MaxMind GeoLite2 City
database, at
/usr/share/GeoIP/GeoLite2-City.mmdbby default.
The full list of required PHP extensions is in the composer.json file.
The Docker setup below provides PHP, Nginx, and MariaDB for you, so it only needs Docker, Composer, and the GeoLite2 database on the host.
Warning
etc/database.sample.sql is out of date. It was
last updated in 2021, and the current code needs tables and columns it does
not have (for example config, user_access, and documents.brief), so
most pages return an error with only the sample loaded. It also creates and
switches to its own database named bnetdocs_phoenix_dev_backup, instead of
importing into the database you choose. Ask a maintainer for a current
schema until the sample is regenerated.
The docker-compose.yml file runs Nginx, PHP-FPM (built from etc/docker/php/Dockerfile), and MariaDB, with this repository mounted into the containers.
- Install the vendor files with
composer install. The containers use thelib/directory from your checkout, so your host PHP needs the extensions listed incomposer.json. On Ubuntu 26.04 these come from thephp8.5-cli,php8.5-curl,php8.5-mbstring,php8.5-mysql, andphp8.5-xmlpackages. - Copy etc/config.sample.json to
etc/config.phoenix.jsonand point themysqlsection at the MariaDB container, using the credentials fromdocker-compose.yml:Keep the other keys in that section from the sample."mysql": { "hostname": "mariadb", "database": "bnetdocs_docker", "username": "bnetdocs_docker", "password": "bnetdocs_docker" }
- Make sure the GeoLite2 City database exists at
/usr/share/GeoIP/GeoLite2-City.mmdbon the host, since it is mounted into the containers from there. - Start everything with
docker compose up -d. The site is served at http://localhost:8080. - Load a database schema into the
bnetdocs_dockerdatabase (see the warning above), for example:On the first start, wait until MariaDB has finished initializing, or the import fails with an access denied error.docker compose exec -T mariadb mariadb -ubnetdocs_docker -pbnetdocs_docker bnetdocs_docker < schema.sql
The Docker Nginx config sets display_errors = On, so errors are returned as
JSON with a stack trace instead of the friendly error page.
Stop the containers with docker compose down. Add -v to also delete the
MariaDB data volume.
Configure Nginx so that it is a FastCGI proxy to php-fpm, and point it at the
src/main.php file for all requests. A sample config exists at
etc/nginx-vhost-sample.conf. Then run
composer install to get the vendor files required for this project.
MariaDB should be configured with the TRADITIONAL,NO_AUTO_VALUE_ON_ZERO modes.
A sample configuration can be found at
etc/mysql-server.sample.cnf.
The PHP date and MariaDB server timezones should be in UTC, though the code will configure for this on its own.
The etc/config.sample.json should be copied to
etc/config.phoenix.json and modified for the environment settings. It will
need at the very least the settings for MariaDB.
Any PHP error that is reported, including warnings and notices, stops the
request with a 500 Internal Server Error. The exception is deprecations, which
are written to the error log and the request continues. Both Nginx configs set
error_reporting = E_ALL, so check the php-fpm error log for deprecations
before upgrading PHP.
Run the same checks as CI before opening a pull request:
# Lint every PHP and template file, showing deprecations as production does
find src/ tests/ -name "*.php" -o -name "*.phtml" | xargs -I{} php -d error_reporting=-1 -d short_open_tag=On -l -f {}
# Run the PHPUnit tests
lib/bin/phpunit
# Run PHPStan
lib/bin/phpstan analyse --memory-limit=1GCI fails the lint on any Deprecated: line, and PHPUnit fails on any PHP
deprecation, warning, or notice a test triggers. PHPStan runs at level 5;
existing findings are recorded in phpstan-baseline.neon. Fix new findings
rather than adding them to the baseline.
If the tests behave differently from CI, run composer install first, since an
old lib/ directory can hold an older PHPUnit than the one composer.lock
pins.
The deploy job writes the deployed tag, commit hash, and commit date to
etc/deploy-version.txt. In a Git checkout that file is ignored, both by Git
and by the code, and the same information is read from Git instead. It is shown
in the page footer, sets the end year of the copyright notice, and versions
asset URLs when bnetdocs.asset_versioning is enabled. The start
year is VersionInfo::COPYRIGHT_START_YEAR in
src/Libraries/Core/VersionInfo.php.