@param null|string $basePath

@return Start
496132
public function createApplication(?string $basePath = null): self
    {
        $basePath ?: $basePath = realpath(__DIR__.'/../../../../../');

        $this->app = new Application($basePath);

        return $this;
    }
486626
public function setBasePath($path)
    {
        if (($this->_basePath = realpath($path)) === false || !is_dir($this->_basePath)) {
            throw new \Exception('程序基本路径' . $this->_basePath . '设置失败');
        }
    }
1163707
public function setBasePath($path, $publicPath = true)
    {
        $this->basePath   = $path;
        $this->publicPath = $publicPath;
    }
868225
public function getBaseFolder( $path = null )
    {

        if ( $path ) {
            return sprintf( '%s/%s', $this->baseFolder, $path );
        }

        return $this->baseFolder;
    }
1257720
public function setRootDir($rootPath = false)
    {
        if (!$rootPath) {
            $this->rootDir = getcwd().DS;
        }

        $this->rootDir = $rootPath.DS;

        return $this;
    }
980326
public function ignorePath($ignorePath = null)
    {
        if (!func_num_args()) {
            return $this->_ignorePath;
        }
        $this->_ignorePath = $ignorePath;
        $this->basePath($this->_basePathTmp);
        return $this;
    }
328299
public function findPath($classname, $basepath = null)
    {
        $path = false;

        if (strpos($classname, $this->_prefix) === 0) {
            $word = strtolower(preg_replace('/(?<=\\w)([A-Z])/', '_\\1', $classname));
            $parts = explode('_', $word);

            if (array_shift($parts) == 'tmpl') {
                $name = array_shift($parts);

                $file = array_pop($parts);

                if (!empty($parts)) {
                    if ($parts[0] != 'view') {
                        foreach ($parts as $key => $value) {
                            $parts[$key] = AnInflector::pluralize($value);
                        }
                    } else {
                        $parts[0] = AnInflector::pluralize($parts[0]);
                    }

                    $path = implode('/', $parts).'/'.$file;
                } else {
                    $path = $file;
                }

                $path = $this->_basepath.'/templates/'.$name.'/'.$path.'.php';
            }
        }

        return $path;
    }
164356
public function createPath($base, $path)
    {
        if (!is_dir($base) || !is_writable($base)) {
            return false;
        }

        if (empty($path)) {
            return false;
        }

        $pieces = explode(self::DS, $path);
        $dir = $base;
        foreach ($pieces as $directory) {
            if (empty($directory)) {
                // @codeCoverageIgnoreStart
                continue; // Handle the / from the exploded path
                // @codeCoverageIgnoreEnd
            }

            $singlePath = $dir . self::DS . $directory;
            if (!file_exists($singlePath) || !is_dir($singlePath)) {
                $create = @mkdir($singlePath);
                if ($create === false) {
                    // @codeCoverageIgnoreStart
                    return false;
                    // @codeCoverageIgnoreEnd
                }
            }
            $dir = $singlePath;
        }

        return true;
    }
665836
public static function make( $base_path ) {
        $name = plugin_basename( $base_path );

        if ( ! isset( self::$instances[$name] ) ) {
            throw new InvalidArgumentException( sprintf( 'Identifier `%s` is not defined', $name ) );
        }

        return self::$instances[$name];
    }
395427
public function setViewPath(string $basePath): self
    {
        $this->viewPath = $basePath;

        if (substr($this->viewPath, -1) != '/') {
            $this->viewPath .= '/';
        }

        return $this;
    }
157267
public static function Combine( string $basePath, string $next1, string $next2 = null ) : string
   {
      if ( empty( $next2 ) )
      {
         return (
            \rtrim( $basePath, "\r\n\t /\\" )
               . \DIRECTORY_SEPARATOR
               . \ltrim( $next1, "\r\n\t /\\" )
         );
      }
      return (
         \rtrim( $basePath, "\r\n\t /\\" )
            . \DIRECTORY_SEPARATOR
            . \trim( $next1, "\r\n\t /\\" )
            . \DIRECTORY_SEPARATOR
            . \ltrim( $next2, "\r\n\t /\\" )
       );
   }
444718
public function getRequestedRoute($basepath)
    {
        if ($basepath == '/') {
            $url = strtolower($_SERVER['REQUEST_URI']);
        } else {
            $url = explode($basepath, strtolower($_SERVER['REQUEST_URI']))[1];
        }

        return $this->_router->getRoute($url);
    }
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;
    }
950082
protected function createAbsoluteUrl(UriInterface $basePath, $targetPath)
    {
        $targetPath = strval($targetPath);
        if ($targetPath === '') {
            return $basePath->withPath('');
        } else {
            if ($this->isRelativeUri($targetPath)) {
                $parts = parse_url($targetPath);
                $path  = isset($parts['path']) ? ltrim($parts['path'], '/') : '';
                $query = isset($parts['query']) ? $parts['query'] : '';
                $hash  = isset($parts['fragment']) ? $parts['fragment'] : '';
                $targetPath = $basePath->withPath($path)->withQuery($query)->withFragment($hash);
            }
        }

        return $targetPath;
    }
672706
public static function within($listenerPath, $basePath)
    {
        return collect(static::getListenerEvents(
            (new Finder)->files()->in($listenerPath), $basePath
        ))->mapToDictionary(function ($event, $listener) {
            return [$event => $listener];
        })->all();
    }
786661
public function locate($class, $basepath = null)
    {
        $path = false;

        if($this->_loader) {
            $path = $this->_loader->findFile($class);
        }

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

		return $this;
	}