Create the application.

@param string $rootPath

@return Silex\Application
499646
public static function run($rootPath)
    {
        /*
         * Load initialization config needed to bootstrap application.
         *
         * In order for paths to be customized and still have the standard
         * index.php (web) and nut (CLI) work, there needs to be a standard
         * place these are defined. This is ".bolt.yml" or ".bolt.php" in the
         * project root (determined above).
         *
         * Yes, YAML and PHP are supported here (not both). YAML works for
         * simple values and PHP supports any programmatic logic if required.
         */
        $config = [
            'application' => null,
            'resources'   => null,
            'paths'       => [],
            'services'    => [],
            'extensions'  => [],
        ];

        $rootPath = Path::canonicalize($rootPath);

        if (file_exists($rootPath . '/.bolt.yml')) {
            $yaml = Yaml::parse(file_get_contents($rootPath . '/.bolt.yml')) ?: [];
            $config = array_replace_recursive($config, $yaml);
        } elseif (file_exists($rootPath . '/.bolt.php')) {
            $php = include $rootPath . '/.bolt.php';
        }

        // An extra handler if a PHP bootstrap is provided, allow the bootstrap file to return
        // a pre-initialized Bolt Application rather than the config array.
        if (isset($php) && is_array($php)) {
            $config = array_replace_recursive($config, $php);
        } elseif (isset($php) && $php instanceof Silex\Application) {
            return $php;
        }

        // If application object is provided, assume it is ready to go.
        if ($config['application'] instanceof Silex\Application) {
            return $config['application'];
        }

        $pathResolverFactoryFactory = \Pimple::share(function () use ($rootPath, $config) {
            $pathResolverFactory = new PathResolverFactory();
            $pathResolverFactory->setRootPath($rootPath);
            $pathResolverFactory->addPaths((array) $config['paths']);

            return $pathResolverFactory;
        });

        $resourcesClass = func_num_args() > 1 ? func_get_arg(1) : Standard::class;
        $resourcesFactory = \Pimple::share(function () use ($config, $resourcesClass, $rootPath, $pathResolverFactoryFactory) {
            // Use resources from config, or instantiate the class based on mapping above.
            if ($config['resources'] instanceof ResourceManager) {
                $resources = $config['resources'];
            } else {
                if ($config['resources'] !== null && is_a($config['resources'], ResourceManager::class, true)) {
                    $resourcesClass = $config['resources'];
                }

                $passPathResolverFactory = false;
                if ($resourcesClass === Composer::class || $resourcesClass === Standard::class) {
                    $passPathResolverFactory = true;
                } else {
                    $r = (new \ReflectionClass($resourcesClass))->getConstructor();
                    if ($r->getNumberOfParameters() > 2 && $r->getParameters()[2]->getClass()->name === PathResolverFactory::class) {
                        $passPathResolverFactory = true;
                    }
                }

                /** @var \Bolt\Configuration\ResourceManager $resources */
                if ($passPathResolverFactory) {
                    $pathResolverFactory = $pathResolverFactoryFactory(null);
                    $resources = new $resourcesClass($rootPath, null, $pathResolverFactory);
                } else {
                    $resources = new $resourcesClass($rootPath);
                }
            }

            // Set any non-standard paths
            foreach ((array) $config['paths'] as $name => $path) {
                $resources->setPath($name, $path, false);
            }

            $resources->verify();

            return $resources;
        });

        // If resources is already initialized, go ahead and customize it now.
        if ($config['resources'] instanceof ResourceManager) {
            $resourcesFactory = $resourcesFactory(null);
        }

        // Create the 'Bolt application'
        $appClass = Application::class;
        if ($config['application'] !== null && is_a($config['application'], Silex\Application::class, true)) {
            $appClass = $config['application'];
        }
        /** @var Silex\Application $app */
        $app = new $appClass([
            'resources'             => $resourcesFactory,
            'path_resolver_factory' => $pathResolverFactoryFactory,
            'path_resolver.root'    => $rootPath,
            'path_resolver.paths'   => (array) $config['paths'],
            'resources.bootstrap'   => $config['resources'] !== null,
        ]);

        foreach ((array) $config['services'] as $service) {
            $params = [];
            if (is_array($service)) {
                $params = reset($service);
                $service = key($service);
            }

            if (is_string($service) && is_a($service, Silex\ServiceProviderInterface::class, true)) {
                $service = new $service();
            }
            if ($service instanceof Silex\ServiceProviderInterface) {
                $app->register($service, $params);
            }
        }

        if (!$config['extensions']) {
            return $app;
        }
        if (!isset($app['extensions'])) {
            throw new LogicException('Provided application object does not contain an extension service, but extensions are defined in bootstrap.');
        }

        $app['extensions'] = $app->share(
            $app->extend(
                'extensions',
                function ($extensions) use ($config) {
                    foreach ((array) $config['extensions'] as $extensionClass) {
                        if (is_string($extensionClass)) {
                            if (!class_exists($extensionClass)) {
                                throw new LogicException(sprintf('Extension class name "%s" is defined in .bolt.yml or .bolt.php, but the class name is misspelled or not loadable by Composer.', $extensionClass));
                            }
                            if (!is_a($extensionClass, ExtensionInterface::class, true)) {
                                throw new LogicException(sprintf('Extension class "%s" must implement %s', $extensionClass, ExtensionInterface::class));
                            }
                            $extensionClass = new $extensionClass();
                        }
                        if (!$extensionClass instanceof ExtensionInterface) {
                            throw new LogicException(sprintf('Extension class "%s" must be an instance of %s', get_class($extensionClass), ExtensionInterface::class));
                        }
                        $extensions->add($extensionClass);
                    }

                    return $extensions;
                }
            )
        );

        return $app;
    }
1255146
public function createApplication()
    {
        // Path for app.php when testing this package
        $testing = __DIR__.'/../vendor/laravel/laravel/bootstrap/app.php';

        // Path for app.php when using this package
        $using = __DIR__.'/../../../laravel/laravel/bootstrap/app.php';

        // Determining correct path
        $path = strlen(env('SELF_TESTING')) ? $testing : $using;

        // Retrieving app.php
        $app = require $path;

        // Bootstrap the app
        $app->make(Kernel::class)->bootstrap();

        // Return Laravel app
        return $app;
    }
312767
protected function createDir($path) {
        if (!is_dir($path)) {
            $this->log->info('Create directory %s', $path);

            $status = mkdir($path, 0775, true);

            if ($status === false) {
                throw new Exception(sprintf(
                    'Unable to create directory %s',
                    $path
                ), ExitApp::RUNTIME_ERROR);
            }
        }

        return $this;
    }
699583
protected function createHandle($filePath)
    {
        if (!$handle = $this->openHandle($filePath)) {
            throw new ResourceNotFoundException("Path '$filePath' cannot be opened");
        }

        $this->applySettings($handle);

        return $handle;
    }
60223
public function create()
    {
        if ($this->rootPath === null) {
            throw new \LogicException('Root path must be set before PathResolver can be created');
        }

        return new PathResolver($this->rootPath, $this->paths);
    }
600230
public function checkRootPath($rootpath){
        /* 设置根目录 */
        $this->rootPath = ftp_pwd($this->link) . '/' . ltrim($rootpath, '/');

        if(!@ftp_chdir($this->link, $this->rootPath)){
            $this->error = '上传根目录不存在！';
            return false;
        }
        return true;
    }
1119709
public static function createByFilePath($filepath) : Repository
    {
        $filename = basename($filepath);
        list($domain, $language, $extension) = explode('.', $filename, 3);

        $yamlParser = new YamlParser();
        $data = $yamlParser->parse(file_get_contents($filepath));

        $emptyArray = [];
        $translations = [];
        self::createPlainRepresentationByArray(
            $translations,
            $language,
            ($data) ?: [],
            $emptyArray,
            ''
        );

        $translationCollection = TranslationCollection::create($translations);

        return new self(
            $translationCollection,
            $filepath,
            $language,
            $domain
        );
    }
1217377
public function generate($basePath, $pretty)
    {
        $fileReflectorRegister = new ReflectorRegister();

        $rootPath = $this->executionPath;
        foreach ($this->files as $file) {
            $currentFileArr = $this->isComponent
                ? explode("/$basePath/", $file)
                : explode("$rootPath", $file);

            if (isset($currentFileArr[1])) {
                $currentFile = str_replace('src/', '', $currentFileArr[1]);
            } else {
                throw new \Exception(
                    sprintf('Failed to determine currentFile: %s', $file)
                );
            }

            $isPhp = strrpos($file, '.php') == strlen($file) - strlen('.php');
            $pathInfo = pathinfo($currentFile);
            $servicePath = $pathInfo['dirname'] === '.'
                ? strtolower($pathInfo['filename'])
                : strtolower($pathInfo['dirname'] . '/' . $pathInfo['filename']);
            $id = $this->isComponent
                ? strtolower($basePath) . '/' . $servicePath
                : $servicePath;

            if ($isPhp) {
                $parser = new CodeParser(
                    $file,
                    $fileReflectorRegister,
                    $rootPath,
                    $this->componentId,
                    $this->manifestPath,
                    $this->release,
                    $this->output,
                    $id,
                    $this->isComponent
                );
            } else {
                $content = file_get_contents($file);
                $parser = new MarkdownParser($currentFile, $content, $id);
            }

            $document = $parser->parse();
            if ($document) {
                $writer = new Writer($document, $this->outputPath, $pretty);
                $writer->write($currentFile);

                $this->types->addType([
                    'id' => $id,
                    'title' => $document['title'],
                    'contents' => $servicePath . '.json'
                ]);
            }
        }
    }
908968
public function create($cacheFilePath = null)
    {
        $map = [];
        if ($cacheFilePath) {
            $map = $this->resolveCachedMap($cacheFilePath);
        }
        if (!is_array($map)) {
            $map = $this->createMap();
            if ($cacheFilePath) {
                $this->cacheMap($cacheFilePath, $map);
            }
        }

        $this->map = $map;

        return $map;
    }
573293
public function setBasePath( string$basePath ):self
	{
		$this->basePath= '/'===substr($basePath,-1) ? substr($basePath,0,-1) : $basePath;

		return $this;
	}
562255
public function basePath($basePath = null)
    {
        if (!func_num_args()) {
            return $this->_basePath;
        }
        $this->_basePath = $basePath;
        return $this;
    }
907322
public static function create(string $root) : Application
    {
        $config = require $root . '/config/neo.config.php';
        $config['root'] = $root;

        $routes = require $root . '/config/routes.config.php';


        // TODO read config and decide which logger to use
        // TODO check if paths exist
        return new Application(
                $config,
                $routes,
                new Router(new Klein(), new ProxyControllerFactory()),
                Endobox::create(\sprintf('%s/src/%s/views', $root, \str_replace('\\', '/', $config['app-namespace']))),
                new NullLogger());
    }
1267111
public static function connectWithPrestashop($rootPath = '/')
  {
    include_once $rootPath.'config/settings.inc.php';
    self::$cnxHandler = new MySql(_DB_SERVER_, _DB_USER_, _DB_PASSWD_, 5432, _DB_NAME_);
    return self::$cnxHandler->connect();
  }
896314
public function createContainer(string $basePath, array $importedFiles = []): ContainerBuilder
    {
        $container = new ContainerBuilder();

        $this->enableSupportForLazyServicesIfPossible($container);

        $loader = $this->createLoader($container, $basePath);
        foreach ($importedFiles as $file) {
            $type = false !== mb_strpos($file, '*') ? 'glob' : null;
            $loader->load($file, $type);
        }

        return $container;
    }
1199321
public function withBasePath($basePath)
    {
        if (!is_string($basePath)) {
            throw new InvalidArgumentException('Uri path must be a string');
        }
        if (!empty($basePath)) {
            $basePath = '/' . trim($basePath, '/'); // <-- Trim on both sides
        }
        $clone = clone $this;

        if ($basePath !== '/') {
            $clone->basePath = $this->filterPath($basePath);
        }

        return $clone;
    }
628159
protected function loadRepository($filepath)
	{
		if (!file_exists($filepath))
		{
			throw $this->createRepositoryException($filepath);
		}

		$dom = new DOMDocument;
		$dom->preserveWhiteSpace = false;
		if (!$dom->loadXML(file_get_contents($filepath), LIBXML_NOERROR))
		{
			throw $this->createRepositoryException($filepath);
		}

		return $dom;
	}
1061027
public function allowCreationForSubProperty($propertyPath)
    {
        $this->forProperty($propertyPath)->setTypeConverterOption(PersistentObjectConverter::class, PersistentObjectConverter::CONFIGURATION_CREATION_ALLOWED, true);
        return $this;
    }