protected function generateOutput($files = null, $namespaces = null, $directories = null, $classmap = null)
    {
        $res = fopen($this->loaderFilePath, 'w');

        if ($res == false) {
            return false;
        }

        fwrite($res, '<?php' . "\n");

        if (isset($this->basePath)) {
            $relativePath = Path::findRelative(dirname($this->loaderFilePath), $this->basePath);
            fwrite($res, '$basePath = __DIR__ . ' . var_export('/' . $relativePath . '/', true) . ";\n");
        }

        fwrite($res, '$loader = new Phalcon\Loader;' . "\n");

        if (Version::getPart(Version::VERSION_MAJOR) >= 3 && Version::getPart(Version::VERSION_MEDIUM) >= 4) {
            fwrite($res, '$loader->setFileCheckingCallback("stream_resolve_include_path");' . "\n");
        }

        if (!empty($files)) {
            fwrite($res, '$loader->registerFiles(' . $this->prepareOutput(array_values($files)) . ');' . "\n");
        }
        if (!empty($directories)) {
            fwrite($res, '$loader->registerDirs(' . $this->prepareOutput(array_values($directories)) . ');' . "\n");
        }
        if (!empty($namespaces)) {
            fwrite($res, '$loader->registerNamespaces(' . $this->prepareOutput($namespaces) . ');' . "\n");
        }
        if (!empty($classmap)) {
            fwrite($res, '$loader->registerClasses(' . $this->prepareOutput($classmap) . ');' . "\n");
        }

        fwrite($res, '$loader->register();' . "\n");

        fclose($res);

        return true;
    }