Login   Register  
PHP Classes
elePHPant
Icontem

File: index.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Tyler Romeo  >  Web API  >  index.php  >  Download  
File: index.php
Role: Application script
Content type: text/plain
Description: Starting point for script
Class: Web API
Web application development framework
Author: By
Last change: Implemented plugin functionality and adjusted for new MAIN_Controller functions.
Date: 4 years ago
Size: 1,138 bytes
 

Contents

Class file image Download
<?php

// Entry point for script.
define("API"true);
define("ID"uniqid("webapi_"true));
define("ROOTDIR"dirname(__FILE__));

// Startup the autoloader
require ROOTDIR '/app/main/Autoloader.php';
MAIN_Autoloader::getInstance(ROOTDIR);

// Get the controller and load the configuration.
$config     = new MAIN_Config();
$config->updateFromFile(ROOTDIR '/config.php');

// Load the custom classes and plugins
MAIN_Autoloader::loadFile(ROOTDIR '/custom.php');
foreach(
scandir(ROOTDIR '/plugins') as $filename) {
    if(
substr($filename, -5) == '.conf') {
        
$config->insertPlugin(substr($filename0, -5),
                              
ROOTDIR '/plugins/$filename');
        
$plugin ROOTDIR '/plugins/' substr($filename0, -5) . '.php';
        
MAIN_Autoloader::loadFile($plugin);
    }
}
        
$controller = new MAIN_Controller();

// Perform the request.
$controller->boot($config);
$controller->initiate();
$controller->send();

// Check for error.
if(!$controller->cleanup()) {
    
// ERROR: Create error page and exit.
    
$controller->initiate();
    
$controller->send();
    
$controller->cleanup();
    exit(
1);
} else {
    
// NO ERROR: Exit.
    
exit(0);
}