Structure
The Inphinit application structure provides an easy-to-understand organization without sacrificing flexibility, which can be adjusted as needed.
Folder structure
.env.sample
This file can be copied to .env after the framework is installed. When installing via Composer, this file is automatically copied to .env.
.env
The .env file contains common configuration values that may vary depending on whether the application is running in a development environment or on a production web server. Its use is not mandatory, as it is possible to configure environment variables in other ways, such as production servers providing an interface to configure such variables via the control panel. The values of the environment variables can be used by the configuration files, located in the system/configs/ directory, by the super-global variable $_ENV, or by the experimental methods:
Inphinit\Experimental\Environment\Env::entry()Inphinit\Experimental\Environment\Env::bool()Inphinit\Experimental\Environment\Env::float()Inphinit\Experimental\Environment\Env::int()
.htaccess
The .htaccess file in the root directory is used to redirect everything to the public/ folder; this is used in environments where you want to run the framework from a subfolder, regardless of the VirtualHost configuration.
web.config
The web.config file configures common HTTP routing and error handling for the IIS server.
Caddyfile
The Caddyfile file configures common HTTP routing and error handling for Caddy and FrankenPHP.
run
Executes CLI commands defined in system/console.php and built-in framework commands. For more details, see Console commands.
run.bat
Executes the CLI commands defined in system/console.php on Windows.
public/
The public/ directory contains your assets, such as images, JavaScript, and CSS. PHP script files independent of the routing system can also be added to this directory.
public/.htaccess
The public/.htaccess file configures common HTTP routing and error handling for the Apache server.
public/index.php
The index.php file is the entry point for the web routing system, and it's also used to configure the INPHINIT_ROOT and INPHINIT_SYSTEM constants to define where the root folder and the project folder are located. Generally, it's not necessary to change these constants.
system/
The system/ directory contains the project structure.
system/console.php
Define custom CLI commands.
system/dev.php
The system/dev.php file functions similarly to system/main.php, serving to configure routes that are available only in the development environment. When in the development environment, system/dev.php is executed first, followed by system/main.php.
system/errors.php
Manages the rendering of custom Error pages generated by SAPI.
system/main.php
Used to define web routes and route scopes.
system/boot/
The system/boot/ directory contains autoloader settings, MIME types (used only in the PHP embedded web server), and metadata for packages installed using Composer.
system/boot/importpackages.php
This script is used by the run pkg:up command to map namespaces, classes, and functions from packages installed via Composer, so they can be used by inphinit-autoload.
system/boot/media_types.php
Maps file extensions to Content-Type headers of the PHP built-in web server.
system/boot/namespaces.php
They contain the mapping of namespaces, classes, and functions from packages installed via Composer for use by inphinit-autoload. While this script can be edited manually, it is preferable to use importpackages.php to configure the Composer package mapping. It can also be used in projects that do not use Composer, allowing namespaces to be defined via the Inphinit\Packages\Import::setItem() method within the importpackages.php file.
system/boot/metadata/
The system/boot/metadata/ directory contains metadata caches for packages installed via Composer, which can be accessed using the Inphinit\Packages\Package::info() method. Usage example:
use Inphinit\Packages\Package;
$version = Package::info($package, Package::VERSION);
echo "{$package} version: {$version}<br>";
$type = Package::info($package, Package::TYPE);
echo "{$package} type: {$type}<br>";
$source = Package::info($package, Package::SOURCE);
echo "{$package} source: {$source}<br>";
$time = Package::info($package, Package::TIME);
echo "{$package} time: {$time}<br>";
$url = Package::info($package, Package::URL);
echo "{$package} url: {$url}<br>";
$description = Package::info($package, Package::DESCRIPTION);
echo "{$package} description: {$description}<br>";
system/configs/
The system/boot/configs/ directory contains configuration files. For more details, visit Configurations.
system/configs/debug.php
The system/configs/debug.php file allows you to configure a shortcut link so that an editor (such as Visual Studio Code) opens the problematic file directly at the indicated line; you can also configure a shortcut link for an AI to analyze the error message or for a search engine. For more details:
system/Controllers/
The system/Controllers/ directory contains controller classes used by the routes. For more details, visit Configuration.
system/Commands/
The system/Commands/ directory contains command classes used by the built-in CLI interface. For more details, visit Console commands.
system/storage/
The system/storage/ directory contains files generated by the application (for example, cache, logs, and temporary files).
system/vendor/
The system/vendor/ directory contains third-party dependencies managed by Composer and the core framework.
system/views/
The system/views/ directory contains files used by the framework's Views system. For more details, visit Views.