index.php 647 B

123456789101112131415161718192021222324252627282930
  1. <?php
  2. use FrameworkX\App;
  3. use Routes\Dispatcher;
  4. require __DIR__ . '/../vendor/autoload.php';
  5. $path = parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH);
  6. $file = __DIR__ . $path;
  7. if (php_sapi_name() === 'cli-server' && is_file($file)) {
  8. return false;
  9. }
  10. if (class_exists(Dotenv\Dotenv::class) && file_exists(__DIR__ . '/../.env')) {
  11. Dotenv\Dotenv::createImmutable(
  12. dirname(__DIR__),
  13. null,
  14. true
  15. )->safeLoad();
  16. }
  17. error_reporting(E_ALL);
  18. $app = new App();
  19. // As rotas (com autenticação JWT e autorização por papel) ficam centralizadas
  20. // em routes/Dispatcher.php.
  21. Dispatcher::register($app);
  22. $app->run();