index.php 905 B

1234567891011121314151617181920212223242526272829303132333435
  1. <?php
  2. require __DIR__ . '/../vendor/autoload.php';
  3. $path = parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH);
  4. $file = __DIR__ . $path;
  5. if (php_sapi_name() === 'cli-server' && is_file($file)) {
  6. return false;
  7. }
  8. if (class_exists(Dotenv\Dotenv::class) && file_exists(__DIR__ . '/../.env')) {
  9. Dotenv\Dotenv::createImmutable(
  10. dirname(__DIR__),
  11. null,
  12. true
  13. )->safeLoad();
  14. }
  15. error_reporting(E_ALL);
  16. use FrameworkX\App;
  17. use Middlewares\HmacAuthMiddleware;
  18. use Middlewares\JWTAuthMiddleware;
  19. $app = new App();
  20. $authHmac = new HmacAuthMiddleware();
  21. $authJwt = new JWTAuthMiddleware();
  22. $app->get('/hmachelloworld', $authHmac,\Controllers\HelloController::class);
  23. $app->get('/jwthelloworld', $authJwt,\Controllers\HelloController::class);
  24. $app->post('/login', \Controllers\LoginController::class);
  25. $app->post('/register', \Controllers\RegisterController::class);
  26. $app->run();