PHP Classes

File: index.php

Recommend this page to a friend!
  Packages of Rogério Taques   PHP RESTful API Framework Kit   index.php   Download  
File: index.php
Role: Example script
Content type: text/plain
Description: Example script
Class: PHP RESTful API Framework Kit
MVC framework to implement REST APIs
Author: By
Last change: Fixes the call for Router->run() at index.php
Date: 9 years ago
Size: 1,324 bytes
 

Contents

Class file image Download
<?php

 /* --------------------------------------------------------
 | PHP API KIT
 | @author Rogerio Taques (rogerio.taques@gmail.com)
 | @version 0.1
 | @license MIT
 | @see http://github.com/rogeriotaques/php-api-kit
 * -------------------------------------------------------- */
 
// define the api timezone 
date_default_timezone_set('Asia/Tokyo');

// is the system been updated?
if (file_exists('.update.lock')) {
  echo json_encode( ['status' => 503, 'message' => 'Service temporarely unavailable. Update in progress.'] );
  exit;
}

// let's define the environment 
// it can be whatever you want. usually will be either 'development' or 'production'
if (!defined('ENV')) {
  define('ENV', getenv('ENV') !== false ? getenv('ENV') : 'development');
}

if (defined('ENV')) {

    switch (ENV)
    {
        case 'development':
            error_reporting(E_ALL & ~E_NOTICE);
            break;
    
        case 'testing':
        case 'production':
            error_reporting(0);
            break;

        default:
            exit('The application environment is not set correctly.');
    }

}

// import loader ...  
if (!require_once('seed/loader.php')) {
  die("Loader not found! Aborted.");
}

use Seed\Router;

// retrieve requested URI 
$uri  = isset($_GET['uri']) ? $_GET['uri'] : '';

// initialise the router 
$router = Router::getInstance( $uri );

// let's rock ...
$router->run();