Skip to content

Configuration

Environment Variables

Fluxor uses a .env file for configuration. Copy .env.example to .env:

bash
cp .env.example .env

Available Options

VariableDescriptionDefault
APP_NAMEApplication name"Fluxor App"
APP_ENVEnvironment (development/production/testing)development
APP_DEBUGDebug modetrue
APP_PORTDevelopment server port8000
APP_TIMEZONETimezoneUTC
APP_KEYApplication key (auto-generated)-

Application Configuration

You can also configure paths programmatically:

php
$app = new Fluxor\App();
$app->setConfig([
    'router_path' => __DIR__ . '/custom/router',
    'views_path' => __DIR__ . '/resources/views',
    'storage_path' => __DIR__ . '/storage',
]);

Config Locking

Protect critical configuration keys from modification:

php
$app = new Fluxor\App();

// Lock specific keys
$app->lockConfig('router_path', 'views_path');

// Lock all configuration
$app->lockConfig();

// Check if a key is locked
if ($app->isConfigLocked('router_path')) {
    // Cannot modify
}

CORS Configuration

Configure CORS globally or per route:

Global CORS

php
$app = new Fluxor\App();
$app->cors()
    ->allowOrigin('https://myfrontend.com')
    ->allowCredentials(true)
    ->enable();
$app->run();

Per-route CORS

php
// app/router/api/users.php
use Fluxor\Flow;
use Fluxor\Response;

Flow::cors([
    'allowed_origins' => ['https://admin.example.com'],
    'allowed_methods' => ['GET', 'POST', 'PUT', 'DELETE'],
    'allowed_headers' => ['Content-Type', 'Authorization'],
    'max_age' => 3600
]);

Flow::GET()->do(fn($req) => Response::json(['users' => []]));

Auto-detection

Fluxor automatically detects:

  • Base Path: Root directory of your application
  • Base URL: Current URL (protocol, host, subdirectory)

No configuration needed!

Released under the MIT License.