File: src/bootstrap/autoload.php

Recommend this page to a friend!
  Classes of Ar Gabid  >  Universal PHP Data Grid  >  src/bootstrap/autoload.php  >  Download  
File: src/bootstrap/autoload.php
Role: Example script
Content type: text/plain
Description: Example script
Class: Universal PHP Data Grid
Display and process data to edit database records
Author: By
Last change: Update of src/bootstrap/autoload.php
Date: 7 months ago
Size: 732 bytes
 

Contents

Download
<?php
/***
 * Package autoloader. If you do not use composer autoloader in your project,
 * then include this file to your application`s initialization file.
 **/
spl_autoload_register(function($className)
{
    if (
strpos($className, 'gdgrid\gd') !== false)
    {
       
$path = explode('\\', str_replace('gdgrid\gd\\', '', $className));

       
$cn = array_pop($path);

       
$file = dirname(dirname(__FILE__))
            .
DIRECTORY_SEPARATOR
           
. ($path ? join(DIRECTORY_SEPARATOR, $path) . DIRECTORY_SEPARATOR : '')
            .
$cn
           
. '.php';

        if (
false === is_file($file))

            throw new \
Exception('Class "' . $className . '" not found.');

        require_once(
$file);
    }
});


For more information send a message to info at phpclasses dot org.