Skip to content
Greg Bowler edited this page May 18, 2026 · 12 revisions

Configuration shapes the application's behaviour without changing the source code. Database credentials, logging behaviour, session setup, routing defaults, and deployment-specific values are all examples of configuration rather than application logic.

The configuration package is documented in more detail at https://www.php.gt/docs/Config/.

How WebEngine loads config

WebEngine starts with its own default config and then layers the project's own config files on top. Environment-specific overrides can then refine those values again.

At a high level the load order is:

  1. WebEngine defaults (vendor/phpgt/webengine/config.default.ini)
  2. project config.ini
  3. environment-specific config files such as development or production overrides, such as config.dev.ini or config.production.ini
  4. environment variables

That gives us a predictable starting point while still letting each environment change only the values it actually needs to change.

See the configuration reference page for a full list of every default value in a WebEngine application.

Important configuration areas

The most important config areas early on are usually:

  • application settings such as namespace and directories
  • routing behaviour
  • session settings
  • database connection settings
  • logging
  • security-related values

As the project grows, these settings make it possible to change deployment details without changing page logic.

Accessing config in application code

Configuration reaches page logic and services through the normal service container. That means a page or class can receive the full config object or, better still, the specific config section it actually needs.

use GT\Config\Config;

function go(Config $config, ExampleRepository $exampleRepository, PaymentProvider $payment):void {
	// Pass specific config values to an object:
	$exampleRepository->connect(
		$config->getString("database.host"),
		$config->getInt("database.port"),
	);
	
	// Pass a whole section of config to an object:
	$paymentProvider->setup($config->getSection("paymentApi"));
}

Passing focused configuration into application classes usually keeps those classes easier to understand. It also makes it clearer which parts of the system are responsible for secrets, credentials, and other environment-specific values.


In the next section we will connect to databases.

Clone this wiki locally