PHP Classes

File: example/loader.php

Recommend this page to a friend!
  Classes of SzpaQ   Application PHP Router Class   example/loader.php   Download  
File: example/loader.php
Role: Example script
Content type: text/plain
Description: Example script
Class: Application PHP Router Class
Route requests with values from $_GET parameters
Author: By
Last change:
Date: 2 years ago
Size: 971 bytes
 

Contents

Class file image Download
<?php

/**
 *
 * LICENCE
 * ALL RIGHTS RESERVED.
 * YOU ARE NOT ALLOWED TO COPY/EDIT/SHARE/WHATEVER.
 * IN CASE OF ANY PROBLEM CONTACT AUTHOR.
 * @author ?ukasz Szpak (szpaaaaq@gmail.com)
 * @Copyright 2018 SzpaQ
 * @license ALL RIGHTS RESERVED
 *
 * * */


if(!defined('PATH')) {
   
define('PATH', __DIR__ .'/../');
}
if(!
defined('CONTROLLER_PATH')) {
   
define('CONTROLLER_PATH', __DIR__ .'/Controllers/');
}

function
auto($class_name)
{
   
    try
    {
       
        if(!
class_exists($class_name))
        {
           
           
$file_path = PATH.'classes/'. str_replace('\\', '/', $class_name) .'.php';
           
            if(
file_exists($file_path))
            {
                               
                require
$file_path;
               
                return;
               
            }
           
           
$file_path = CONTROLLER_PATH.'/'. str_replace('\\', '/', $class_name) .'.php';
           
            if(
file_exists($file_path))
            {
               
                require
$file_path;
               
                return;
               
            }
           
               
        }

       
    }
    catch(
Exception $e)
    {
        exit(
$e->getMessage());
   
    }

}

spl_autoload_register('auto');