Configurations

Inphinit offers several configuration approaches tailored to different purposes, including the use of environment variables.

Environmental variables

Environment variables can be configured directly in the environment, directives, or via the .env file. The following is a description of the application's default environment variables:

Variable Description
APP_ENVIRONMENT Defines the current environment; any value is accepted. By default, the value APP_ENVIRONMENT=development will activate the framework debugger
APP_BUILT_IN_HOST Used only for the built-in web server, this sets the default host. Note that the host can still be overridden via the command line (e.g., run serve --host 0.0.0.0)
APP_BUILT_IN_PORT Used only for the built-in web server, this sets the default port. Note that the port can still be overridden via the command line (e.g., run serve --port 8001)
APP_FORWARDED_PROTO -
APP_FORWARDED_HOST -
APP_FORWARDED_PORT -
APP_SESSION_EXPIRES Used to determine how long a session created by an instance of Inphinit\Session should last
APP_COMPOSER_AUTOLOAD Enables or disables composer-autoload. Note that infinit-autoload is the default, and it works alongside composer and is highly optimized. Composer-autoload should only be used if you have a conflicting third-party package that requires composer-autoload
APP_SKIP_ENV_FILE This variable is optional, but very useful when running on servers that offer environment variable configuration or panel-based settings, or when using Docker, where loading a .env file is unnecessary. In these scenarios, setting APP_SKIP_ENV_FILE=1 will prevent the .env file from being loaded unnecessarily

By default, the framework will load the .env file, but if you want to define the variables manually or via a panel on your server, or if your server provides a specific feature for this scenario, you can use APP_SKIP_ENV_FILE=1, as mentioned before. Below is an example via terminal for local use in development environments:

APP_ENVIRONMENT=development APP_BUILT_IN_HOST=localhost APP_BUILT_IN_PORT=5000 APP_SESSION_EXPIRES=86400 APP_SKIP_ENV_FILE=1 ./run serve [Mon Dec 8 15:01:24 2025] PHP 8.5.0RC4 Development Server (http://localhost:5000) started

Autoload

Inphinit Autoloader is an optimized autoloader that allows you to load classes installed via composer. To use Composer Autoloader, set the value APP_COMPOSER_AUTOLOAD=1 in environment variables (or .env file).

It's important to note that infinit-autoload is quite optimized and you will rarely need to change it; you should only do so if some third-party library is causing a conflict that requires composer-autoload.

Constants

The standard constants in the framework allow for changes in behavior and customized implementations without needing to modify existing resources.

Constant Editable Description
INPHINIT_ROOT ✔️
is editable
It must contain the path of the folder where index.php is located
INPHINIT_START ✔️
is editable
It can be used for simple performance testing, estimating the time for something to execute, from the start of the execution
INPHINIT_SYSTEM ✔️
is editable
It must contain the path of the system folder, this folder contains the project, data and packages
INPHINIT_PATH
no editable
Contains the path of the current URL request. This constant is mainly used by the routing system
INPHINIT_URL
no editable
Contains the URL where the application is located. This constant is mainly used by the route scoping system
INPHINIT_MAINTENANCE
no editable
Contains the location of the file that defines whether the application is in maintenance mode. The value is stored in a constant to avoid unnecessary coupling, in case you need to implement something specific for the maintenance mode behavior

Configuration files

In the system/Configs folder you can add PHP scripts that contain an array with values suitable for different uses. Note that it is not recommended to store sensitive values directly.

The default project has some entirely hypothetical usage examples, which should be adjusted or used simply to understand the mechanism and should be tailored to your needs. Hypothetically, if you were to use the MySQLi API to connect, you could create a configuration file like system/Configs/databases/main.php and add something like:

<?php use Inphinit\Experimental\Environment\Env; return array( 'host' => Env::entry('DB_HOST'), 'user' => Env::entry('DB_USER'), 'pass' => Env::entry('DB_PASS'), 'database' => Env::entry('DB_DATABASE'), 'charset' => 'utf8', 'report_mode' => MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT, );

And then use it with the Inphinit\Config class, hypothetical example:

<?php use Inphinit\Configs; $config = new Configs('databases.main'); // from: system/Configs/databases/main.php mysqli_report($config->report_mode); $mysqli = new mysqli($config->host, $config->user, $config->pass, $config->database);
Go to homepage
Star us on Github