first commit
This commit is contained in:
10
public/.htaccess
Executable file
10
public/.htaccess
Executable file
@@ -0,0 +1,10 @@
|
||||
<IfModule mod_rewrite.c>
|
||||
RewriteEngine On
|
||||
RewriteBase /
|
||||
|
||||
# Se não for arquivo nem pasta, manda tudo pro index.php
|
||||
RewriteCond %{REQUEST_FILENAME} !-f
|
||||
RewriteCond %{REQUEST_FILENAME} !-d
|
||||
|
||||
RewriteRule ^ index.php [L]
|
||||
</IfModule>
|
||||
92
public/index.php
Executable file
92
public/index.php
Executable file
@@ -0,0 +1,92 @@
|
||||
<?php
|
||||
// ============================
|
||||
// Configurações de erro
|
||||
// ============================
|
||||
ini_set(option: 'display_errors', value: 1);
|
||||
ini_set(option: 'display_startup_errors', value: 1);
|
||||
ini_set(option: 'log_errors', value: 1);
|
||||
ini_set(option: 'error_log', value: __DIR__ . "/../app/Storage/Logs/php_errors.log");
|
||||
error_reporting(error_level: E_ALL);
|
||||
|
||||
// Importa autoload do Composer
|
||||
require_once realpath(path: __DIR__ . '/../vendor/autoload.php');
|
||||
|
||||
// ============================
|
||||
// Namespaces usados
|
||||
// ============================
|
||||
use AxiumPHP\Core\Router;
|
||||
use Zampet\Config\Config;
|
||||
use AxiumPHP\Core\LoggerService;
|
||||
use Zampet\Module\Auth\v0\Middlewares\AuthMiddleware;
|
||||
|
||||
// ============================
|
||||
// Configurações globais
|
||||
// ============================
|
||||
$Config = Config::getInstance();
|
||||
|
||||
// ============================
|
||||
// Define constantes do sistema
|
||||
// ============================
|
||||
const ROUTER_MODE = 'JSON';
|
||||
const APP_SYS_MODE = 'DEV'; // PROD = Production, DEV = Development
|
||||
define(constant_name: 'ROOT_SYSTEM_PATH', value: realpath(path: __DIR__ . "/.."));
|
||||
define(constant_name: 'INI_SYSTEM_PATH', value: realpath(path: __DIR__ . "/../app"));
|
||||
define(constant_name: 'MODULE_PATH', value: realpath(path: __DIR__ . "/../app/Module"));
|
||||
define(constant_name: 'STORAGE_FOLDER_PATH', value: realpath(path: __DIR__ . "/../app/Storage"));
|
||||
|
||||
// ============================
|
||||
// Inicializa LoggerService
|
||||
// ============================
|
||||
LoggerService::init(
|
||||
driver: LoggerService::DRIVER_FILE,
|
||||
logDir: __DIR__ . '/../app/Storage/Logs'
|
||||
);
|
||||
|
||||
// ============================
|
||||
// Define origens permitidas
|
||||
// ============================
|
||||
const ROUTER_ALLOWED_ORIGINS = [
|
||||
'*'
|
||||
];
|
||||
|
||||
// ============================
|
||||
// Define fuso horário
|
||||
// ============================
|
||||
date_default_timezone_set(timezoneId: $Config->get(key: "SYSTEM_TIMEZONE"));
|
||||
|
||||
// ============================
|
||||
// Inicia sessão se necessário
|
||||
// ============================
|
||||
if (session_status() === PHP_SESSION_NONE) {
|
||||
session_start();
|
||||
}
|
||||
|
||||
// ============================
|
||||
// Inicializa o roteador
|
||||
// ============================
|
||||
new Router();
|
||||
|
||||
// ============================
|
||||
// Carregamento de Módulos Essenciais do sistema
|
||||
// ============================
|
||||
require_once MODULE_PATH . '/Auth/v0/bootstrap.php';
|
||||
|
||||
Router::group(
|
||||
prefix: '/module',
|
||||
callback: function() {
|
||||
// Carrega módulo do Tutor
|
||||
require_once MODULE_PATH . '/Tutor/v0/bootstrap.php';
|
||||
|
||||
},
|
||||
middlewares: [
|
||||
AuthMiddleware::class."::handle"
|
||||
]
|
||||
);
|
||||
|
||||
// ============================
|
||||
// Dispara o roteador
|
||||
// ============================
|
||||
// Só dispara Router se for uma requisição web
|
||||
if (php_sapi_name() !== 'cli') {
|
||||
Router::dispatch();
|
||||
}
|
||||
Reference in New Issue
Block a user