Пример #1
0
            return true;
        }
        return false;
    }
    /**
     * Registers this instance as an autoloader.
     *
     * @param bool $prepend
     */
    public function register($prepend = false)
    {
        spl_autoload_register(array($this, 'loadClass'), true, $prepend);
    }
    /**
     * Removes this instance from the registered autoloaders.
     */
    public function unregister()
    {
        spl_autoload_unregister(array($this, 'loadClass'));
    }
}
$loader = new Psr4ClassLoader();
$loader->addPrefix('lib\\', __DIR__ . '/lib');
$loader->addPrefix('services\\', __DIR__ . '/services');
$loader->addPrefix('models\\', __DIR__ . '/models');
$loader->addPrefix('tests\\', __DIR__ . '/tests');
$loader->addPrefix('db\\', __DIR__ . '/lib/db');
$loader->addPrefix('notifier\\', __DIR__ . '/lib/notifier');
$loader->addPrefix('tests\\', __DIR__ . '/tests');
$loader->addPrefix('timesync\\', __DIR__ . '/lib/Timesync');
$loader->register();
Пример #2
0
     */
    public function loadClass($class)
    {
        $file = $this->findFile($class);
        if (null !== $file) {
            require $file;
            return true;
        }
        return false;
    }
    /**
     * Registers this instance as an autoloader.
     *
     * @param bool $prepend
     */
    public function register($prepend = false)
    {
        spl_autoload_register(array($this, 'loadClass'), true, $prepend);
    }
    /**
     * Removes this instance from the registered autoloaders.
     */
    public function unregister()
    {
        spl_autoload_unregister(array($this, 'loadClass'));
    }
}
$loader = new Psr4ClassLoader();
$loader->addPrefix('libDb\\', __DIR__ . '/libDb');
$loader->addPrefix('models\\', __DIR__ . '/models');
$loader->register();
Пример #3
0
            require $file;
            return true;
        }
        return false;
    }
    /**
     * Registers this instance as an autoloader.
     *
     * @param bool $prepend
     */
    public function register($prepend = false)
    {
        spl_autoload_register(array($this, 'loadClass'), true, $prepend);
    }
    /**
     * Removes this instance from the registered autoloaders.
     */
    public function unregister()
    {
        spl_autoload_unregister(array($this, 'loadClass'));
    }
}
$loader = new Psr4ClassLoader();
$loader->addPrefix('controllers\\', __DIR__ . '/controllers');
$loader->addPrefix('models\\', __DIR__ . '/models');
$loader->addPrefix('db\\', __DIR__ . '/db');
$loader->addPrefix('utilities\\', __DIR__ . '/utilities');
$loader->addPrefix('api\\', __DIR__ . '/api');
$loader->addPrefix('timeSync\\', __DIR__ . '/timeSync');
$loader->addPrefix('mailer\\', __DIR__ . '/mailer');
$loader->register();