Skip to content

Configuration ​

Configuration files live in config/. Each file returns a PHP array and maps to a key you access with Config::get() or the config() helper.

Environment variables ​

All sensitive or environment-specific values go in .env:

ini
APP_NAME=HexaGen
APP_ENV=production        # local | production | testing
APP_DEBUG=false           # show stack traces (never true in production)
APP_URL=https://my-app.com
APP_KEY=your-32-char-random-key

DB_DRIVER=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=my_app
DB_USER=root
DB_PASSWORD=secret

CACHE_DRIVER=redis
REDIS_HOST=127.0.0.1
REDIS_PORT=6379

QUEUE_DRIVER=database

MAIL_DRIVER=smtp
MAIL_HOST=smtp.mailgun.org
MAIL_PORT=587
MAIL_USERNAME=
MAIL_PASSWORD=
MAIL_FROM=noreply@my-app.com

JWT_SECRET=your-jwt-secret
SESSION_NAME=hexagen_session

AWS_ACCESS_KEY_ID=
AWS_SECRET_ACCESS_KEY=
AWS_DEFAULT_REGION=us-east-1
AWS_BUCKET=

Reading config values ​

php
config('app.name');                    // "HexaGen"
config('app.debug', false);           // with default
Config::get('mail.driver');           // static access

Caching config for production ​

bash
php hexaphp config:cache    # compiles all config files into a single cached file
php hexaphp config:clear    # removes the cache

Always run config:cache before deploying to production.

Available config files ​

FileKeyContents
config/app.phpappName, URL, debug, key, timezone
config/auth.phpauthGuards, providers
config/cache.phpcacheDriver, TTL, Redis options
config/cors.phpcorsAllowed origins, methods, headers
config/csrf.phpcsrfExcluded routes
config/filesystems.phpfilesystemsDisks (local, S3)
config/logging.phploggingChannel, log path
config/mail.phpmailDriver, SMTP settings
config/queue.phpqueueDriver, connection
config/rate-limiting.phprate-limitingMax attempts, decay

Application paths ​

Every path the framework uses (.env, config/, src/Slices/, database/, resources/views/, lang/, storage/, public/) is resolved against the application root. By default that is the root Composer package: this repository when you work on the framework itself, or your app when the framework is installed in vendor/.

php
use HexaGen\Core\Application;

Application::basePath();               // /var/www/my-app
Application::basePath('database');     // /var/www/my-app/database
Application::configPath('app.php');    // /var/www/my-app/config/app.php
Application::slicesPath('Flights');    // /var/www/my-app/src/Slices/Flights
Application::storagePath('logs');      // /var/www/my-app/storage/logs
Application::frameworkPath();          // where HexaGen PHP itself is installed

To use a different root (for example in tests), set it before booting the kernel:

php
Application::setBasePath('/path/to/app');

When the framework is a dependency, the CLI is available as vendor/bin/hexaphp. Error pages fall back to the framework's own views when your app does not define resources/views/errors/.

Telemetry ​

Request tracing is off by default. Turn it on with:

ini
TELEMETRY_ENABLED=true
OTEL_EXPORTER=otlp                       # or log
OTEL_EXPORTER_OTLP_ENDPOINT=http://collector:4318/v1/traces
OTEL_SERVICE_NAME=my-app
TELEMETRY_TRACE_QUERIES=false            # one span per SQL query when true

Each request gets a span and an X-Trace-Id response header. The otlp exporter sends spans to an OpenTelemetry collector (Jaeger, Grafana Tempo, Zipkin). The log exporter writes one debug line per request to the log, which is fine for local debugging but grows the log file quickly in production. Measured with FrankenPHP in worker mode, the log exporter cut throughput on a JSON route by about a third.

Released under the MIT License.