-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbootstrap.php
More file actions
28 lines (22 loc) · 785 Bytes
/
bootstrap.php
File metadata and controls
28 lines (22 loc) · 785 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
<?php
/**
* Bootstrap da aplicação
* Configura tudo o que é necessário para a API funcionar
*/
// Carrega o autoload do Composer
require_once __DIR__ . '/vendor/autoload.php';
// Configura o header JSON para toda a API
header('Content-Type: application/json; charset=utf-8');
// Inicializa EnvConfig (carrega variáveis de ambiente e timezone)
\src\Config\EnvConfig::getInstance();
// Registra as dependências no Container
require_once __DIR__ . '/dependencies.php';
// Tratamento global de erros para APIs JSON
set_exception_handler(function ($e) {
http_response_code(500);
echo json_encode([
'sucesso' => false,
'erro' => 'Erro interno do servidor',
'mensagem' => $e->getMessage()
], JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE);
});