Skip to content

Development Environment

Arthu Santiago edited this page Nov 30, 2026 · 1 revision

Development Environment

This section is for people who change KeyAnyWhere's code. This page builds on the Quick Start, which already gives you a running development install. It adds what development needs on top of that: the debugging tools, the test database, coverage support and the switches that only exist in development.

Before you start

Finish the Quick Start. You then have the code, the development dependencies (composer install without --no-dev), both databases and config/.env.

How KeyAnyWhere knows it is in development

KeyAnyWhere doesn't read an APP_ENV variable. It considers itself in development when all three are true: debug is on (DEBUG=true in config/.env), the file config/.env exists, and the request has a SERVER_NAME. Several behaviors depend on this:

In development In production
DebugKit toolbar loaded not loaded
CSRF cookie Secure-csrfToken __Secure-csrfToken
No Content-Security-Policy, no X-Frame-Options both sent
Plain HTTP accepted HTTPS only

config/.env is loaded by config/bootstrap.php only when it exists and the process has no SERVER_NAME in its environment, and it never overrides a variable that is already set.

1. Add coverage support (optional)

Code coverage and mutation tests (Code Quality) need a coverage driver. PCOV is the fastest:

sudo apt install -y php8.4-pcov
php -m | grep -i pcov

2. Skip the second factor while developing (optional)

Typing a 6-digit code on every login gets tedious. In development only, KeyAnyWhere can accept any code, if you opt in explicitly:

echo 'export DESENVOLVIMENTO_IGNORA_2FA="true"' >> config/.env

The switch only works when the environment is development and the variable is true: a production install copied from the examples could also have debug on and a config/.env, so the environment alone is not enough. The variable is deliberately left out of config/.env.example. The test suite never sets it, so 2FA is always tested for real.

3. Load example data

If you skipped it in the Quick Start, ten example categories with twenty entries each make the screens easier to work with:

bin/cake seeds run CategoriasSeed,EntradasSeed

4. Check that it worked

Start the server and open http://localhost:8765/. With DEBUG=true, the DebugKit icon shows in the bottom-right corner of every page.

bin/cake server

Local overrides of the shared configs

phpstan.neon.dist and phpcs.xml.dist are the shared configurations of the checks. A local phpstan.neon or phpcs.xml (both ignored by Git) overrides them, for example to add a plugin's paths:

printf '%s\n' 'includes:' '    - phpstan.neon.dist' 'parameters:' '    paths:' '        - plugins/MyPlugin/src' > phpstan.neon

Next step

Running Tests

Clone this wiki locally