src/CarteBlanche/App/Loader.php
public static function loadClass($classname, $type = null, $silent = false)
    {
        // search in bundles
        $bundles = CarteBlanche::getContainer()->get('bundles');
        $full_classname = $type.$classname;
        $classfile = ucfirst($classname).'.php';
        if (!empty($bundles)) {
            foreach($bundles as $_n=>$_bundle) {
                $_namespace = $_bundle->getNamespace();
                if (!empty($type)) {
                    $bundle_file = rtrim($_bundle->getDirectory(), '/').'/'
                        .rtrim($type, '/').'/'
                        .$classfile;
                    $full_namespace = '\\'.$_namespace.'\\'.$type.'\\'.ucfirst($classname);
                    if ($_ce = self::classExists($full_namespace)) {
                        return $full_namespace;
                    } elseif ($_f = Locator::locate($bundle_file)) {
                        if (true===self::load($_f)) {
                            return $full_namespace;
                        }
                    }
                } else {
                    if ($_namespace == substr(trim($classname, '\\'), 0, strlen($_namespace))) {
                        $bundle_file = str_replace('\\', DIRECTORY_SEPARATOR,
                            rtrim($_bundle->getDirectory(), '/')
                            .substr(trim($classname, '\\'), strlen($_namespace))
                            .'.php'
                        );
                        $full_namespace = $classname;
                        if ($_ce = self::classExists($full_namespace)) {
                            return $full_namespace;
                        } elseif ($_f = Locator::locate($bundle_file)) {
                            if (true===self::load($_f)) {
                                return $classname;
                            }
                        }
                    }
                }
            }
        }

        // silently return if the class has not been found
        if (0!==error_reporting() && true!==$silent) {
            throw new ErrorException("Class '$classname' not found!");
        }
        return false;
    }
public static function loadClass($classname, $type = null, $silent = false)
    {
        // search in bundles
        $bundles = CarteBlanche::getContainer()->get('bundles');
        $full_classname = $type.$classname;
        $classfile = ucfirst($classname).'.php';
        if (!empty($bundles)) {
            foreach($bundles as $_n=>$_bundle) {
                $_namespace = $_bundle->getNamespace();
                if (!empty($type)) {
                    $bundle_file = rtrim($_bundle->getDirectory(), '/').'/'
                        .rtrim($type, '/').'/'
                        .$classfile;
                    $full_namespace = '\\'.$_namespace.'\\'.$type.'\\'.ucfirst($classname);
                    if ($_ce = self::classExists($full_namespace)) {
                        return $full_namespace;
                    } elseif ($_f = Locator::locate($bundle_file)) {
                        if (true===self::load($_f)) {
                            return $full_namespace;
                        }
                    }
                } else {
                    if ($_namespace == substr(trim($classname, '\\'), 0, strlen($_namespace))) {
                        $bundle_file = str_replace('\\', DIRECTORY_SEPARATOR,
                            rtrim($_bundle->getDirectory(), '/')
                            .substr(trim($classname, '\\'), strlen($_namespace))
                            .'.php'
                        );
                        $full_namespace = $classname;
                        if ($_ce = self::classExists($full_namespace)) {
                            return $full_namespace;
                        } elseif ($_f = Locator::locate($bundle_file)) {
                            if (true===self::load($_f)) {
                                return $classname;
                            }
                        }
                    }
                }
            }
        }

        // silently return if the class has not been found
        if (0!==error_reporting() && true!==$silent) {
            throw new ErrorException("Class '$classname' not found!");
        }
        return false;
    }
Class autoloader to scan bundles directory

@param   string          $classname  The name of the class to load
@param   null/string     $type       The namespace type (Controller for example)
@param   bool            $silent     Exit silently if not found (default is false)
@return  bool/string     TRUE if the classfile had been found
@throws  \CarteBlanche\Exception\ErrorException if the class can't be found & $silent is false