PHP Classes

File: app/config/bootstrap.php

Recommend this page to a friend!
  Classes of John Marlo Factorin   Bit Framework   app/config/bootstrap.php   Download  
File: app/config/bootstrap.php
Role: Configuration script
Content type: text/plain
Description: Configuration script
Class: Bit Framework
MVC based Web application development framework
Author: By
Last change: Update of app/config/bootstrap.php
Date: 2 months ago
Size: 617 bytes
 

Contents

Class file image Download
<?php

use Snipworks\BitCore\Inflector;
use
Snipworks\BitCore\BitException;

spl_autoload_register(function ($class) {
    if (
Inflector::ends('Controller', $class)) {
       
$dir = 'app/controllers';
    } elseif (
Inflector::ends('Service', $class)) {
       
$dir = 'app/services';
    } else {
       
$dir = 'app/models';
    }

   
$path = sprintf('%s/%s.php', $dir, $class);
    if (!
file_exists(__ROOT__ . $path)) {
        throw new
BitException(sprintf('[Autoload] Class %s not found (path: %s)', $class, $path));
    }

   
/** @noinspection PhpIncludeInspection */
   
require_once(__ROOT__ . $path);
});