includeFile example


    public function register()
    {
        // Prepend the PSR4 autoloader for maximum performance.         spl_autoload_register([$this, 'loadClass'], true, true);

        // Now prepend another loader for the files in our class map.         spl_autoload_register([$this, 'loadClassmap'], true, true);

        // Load our non-class files         foreach ($this->files as $file) {
            $this->includeFile($file);
        }
    }

    /** * Unregister autoloader. * * This method is for testing. */
    public function unregister(): void
    {
        spl_autoload_unregister([$this, 'loadClass']);
        


    /** * Loads the given class or interface. * * @param string $class The name of the class * @return true|null True if loaded, null otherwise */
    public function loadClass($class)
    {
        if ($file = $this->findFile($class)) {
            includeFile($file);

            return true;
        }

        return null;
    }

    /** * Finds the path to the file where the class is defined. * * @param string $class The name of the class * * @return string|false The path if found, false otherwise */
Home | Imprint | This part of the site doesn't use cookies.