public function setup(bool $force = false, bool $useCache = true): void
    {
        // If route's have already been setup, no need to do it again
        if (self::$setup && ! $force) {
            return;
        }

        self::$setup = true;

        // If the application should use the routes cache file
        if ($useCache && $this->app->config()['routing']['useCache']) {
            $this->setupFromCache();

            // Then return out of setup
            return;
        }

        self::$collection = new RouteCollection();

        // If annotations are enabled and routing should use annotations
        if (
            $this->app->config()['routing']['useAnnotations']
            && $this->app->config()['annotations']['enabled']
        ) {
            // Setup annotated routes
            $this->setupAnnotatedRoutes();

            // If only annotations should be used for routing
            if ($this->app->config()['routing']['useAnnotationsExclusively']) {
                // Return to avoid loading routes file
                return;
            }
        }

        // Include the routes file
        // NOTE: Included if annotations are set or not due to possibility of
        // routes being defined within the controllers as well as within the
        // routes file
        require $this->app->config()['routing']['filePath'];
    }
public function setup(bool $force = false, bool $useCache = true): void
    {
        // If route's have already been setup, no need to do it again
        if (self::$setup && ! $force) {
            return;
        }

        self::$setup = true;

        // If the application should use the routes cache file
        if ($useCache && $this->app->config()['routing']['useCache']) {
            $this->setupFromCache();

            // Then return out of setup
            return;
        }

        self::$collection = new RouteCollection();

        // If annotations are enabled and routing should use annotations
        if (
            $this->app->config()['routing']['useAnnotations']
            && $this->app->config()['annotations']['enabled']
        ) {
            // Setup annotated routes
            $this->setupAnnotatedRoutes();

            // If only annotations should be used for routing
            if ($this->app->config()['routing']['useAnnotationsExclusively']) {
                // Return to avoid loading routes file
                return;
            }
        }

        // Include the routes file
        // NOTE: Included if annotations are set or not due to possibility of
        // routes being defined within the controllers as well as within the
        // routes file
        require $this->app->config()['routing']['filePath'];
    }
public function setup ( bool $ force = false , bool $ useCache = true ) : void { // If route's have already been setup, no need to do it again if ( self :: $ setup && ! $ force ) { return ; } self :: $ setup = true ; // If the application should use the routes cache file if ( $ useCache && $ this -> app -> config ( ) [ 'routing' ] [ 'useCache' ] ) { $ this -> setupFromCache ( ) ; // Then return out of setup return ; } self :: $ collection = new RouteCollection ( ) ; // If annotations are enabled and routing should use annotations if ( $ this -> app -> config ( ) [ 'routing' ] [ 'useAnnotations' ] && $ this -> app -> config ( ) [ 'annotations' ] [ 'enabled' ] ) { // Setup annotated routes $ this -> setupAnnotatedRoutes ( ) ; // If only annotations should be used for routing if ( $ this -> app -> config ( ) [ 'routing' ] [ 'useAnnotationsExclusively' ] ) { // Return to avoid loading routes file return ; } } // Include the routes file // NOTE: Included if annotations are set or not due to possibility of // routes being defined within the controllers as well as within the // routes file require $ this -> app -> config ( ) [ 'routing' ] [ 'filePath' ] ; }
Setup routes.

@param bool $force    [optional] Whether to force setup
@param bool $useCache [optional] Whether to use cache

@throws \InvalidArgumentException
@throws \Valkyrja\Dispatcher\Exceptions\InvalidClosureException
@throws \Valkyrja\Dispatcher\Exceptions\InvalidDispatchCapabilityException
@throws \Valkyrja\Dispatcher\Exceptions\InvalidFunctionException
@throws \Valkyrja\Dispatcher\Exceptions\InvalidMethodException
@throws \Valkyrja\Dispatcher\Exceptions\InvalidPropertyException

@return void
Setup routes .