PHP Classes

File: api/bootstrap.php

Recommend this page to a friend!
  Classes of Faris AL-Otabi   Simple PHP API Framework   api/bootstrap.php   Download  
File: api/bootstrap.php
Role: Example script
Content type: text/plain
Description: Example script
Class: Simple PHP API Framework
Create new APIs using controller classes
Author: By
Last change:
Date: 11 months ago
Size: 603 bytes
 

Contents

Class file image Download
<?php

require dirname(__DIR__) . '/vendor/autoload.php';

header("Content-type: application/json; charset=UTF-8");

set_error_handler("MY_Framework\ErrorHandler::handleError");
set_exception_handler("MY_Framework\ErrorHandler::handleException");

use
MY_Framework\JWTCodec;

$dotenv = Dotenv\Dotenv::createImmutable(dirname(__DIR__));

$dotenv->load();

$path = parse_url($_SERVER["REQUEST_URI"], PHP_URL_PATH);

$parts = explode("/", $path);

$route = $parts[2];

$id = $parts[3] ?? null;

$method = $_SERVER['REQUEST_METHOD'];

$secret_key = $_ENV['SECRET_KEY'];

$codec = new JWTCodec($secret_key);