feat: add initial setup for KrothiumAPI with .htaccess and index.php

- Created .htaccess for URL rewriting to route all requests to index.php
- Added index.php to bootstrap the KrothiumAPI with environment variables and configuration settings
- Configured application mode, paths, router settings, session management, error logging, and logging driver
This commit is contained in:
2026-09-09 19:00:36 -03:00
parent aea6825de6
commit 50df29daa7
6 changed files with 1432 additions and 0 deletions
+10
View File
@@ -0,0 +1,10 @@
<IfModule mod_rewrite.c>
RewriteEngine On
# Se for arquivo ou pasta real, deixa passar
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# Tudo vai pro front controller
RewriteRule ^ index.php [L,QSA]
</IfModule>
+51
View File
@@ -0,0 +1,51 @@
<?php
// Importa autoload do Composer
require_once realpath(path: __DIR__ . '/../vendor/autoload.php');
use Dotenv\Dotenv;
use KrothiumAPI\KrothiumAPI;
// Carrega variáveis de ambiente
$dotenv = Dotenv::createImmutable(paths: __DIR__ . '/..');
$dotenv->load();
// ======================================
// Inicializa KrothiumAPI com configs
// ======================================
KrothiumAPI::init(config: [
'app' => [
'mode' => $_ENV['APP_MODE'] ?? 'DEV', // DEV | PROD
],
'paths' => [
'root' => __DIR__ . '/..',
'src' => __DIR__ . '/../app',
'module' => __DIR__ . '/../app/Module',
'storage' => __DIR__ . '/../storage',
'component' => __DIR__ . '/../app/Common/Component',
],
'router' => [
'base_path' => $_ENV['ROUTER_BASE_PATH'] ?? '',
'allowed_origins' => ['*'],
],
'system' => [
'enable_session' => true,
'default_timezone' => 'America/Fortaleza',
],
'errors' => [
'error_log' => __DIR__ . '/../storage/Logs/php-error.log',
],
'logger' => [
'driver' => 'FILE',
'logDir' => __DIR__ . '/../storage/Logs'
],
'constants' => [
// Constantes extras específicas da aplicação, se precisar.
]
]);
// Importa rotas da API v0
// ============================
// Dispara o roteador
// ============================
KrothiumAPI::routerDispatch();