-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathautoload.config.php
More file actions
28 lines (24 loc) · 888 Bytes
/
autoload.config.php
File metadata and controls
28 lines (24 loc) · 888 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
<?php
namespace PluSQL;
/**
* This file provides a default autoload implementation for those not using https://github.com/iaindooley/RocketSled
*/
spl_autoload_register(function($class)
{
//IF THIS IS A NAMESPACED CLASS AND IT'S PART OF plusql
if((strpos($class,'\\') !== FALSE) && (strpos($class,'PluSQL') === 0))
{
$split = explode('\\',$class);
array_shift($split);
$file = classToFile(array_pop($split));
$filename = dirname(__FILE__).'/'.implode('/',$split).'/'.$file;
}
else
$filename = dirname(__FILE__).'/'.classToFile($class);
if(file_exists($filename))
require_once($filename);
});
function classToFile($class)
{
return strtolower(ltrim(preg_replace('/([A-Z])/','_\1',$class),'_')).'.class.php';
}