original_string: protected function startRoutingPlugin($app)
      {
          $this->requiresPlugins(Paths::class, Resources::class);
          $this->onRegister('routing', function (Application $app) {
              if (PHP_SAPI !== 'cli' || $this->app->runningUnitTests()) {
                  $router = $app->make('router');
                  $kernel = $app->make('Illuminate\Contracts\Http\Kernel');
  
                  foreach ($this->prependMiddleware as $class) {
                      $kernel->prependMiddleware($class);
                  }
  
                  foreach ($this->middleware as $class) {
                      $kernel->pushMiddleware($class);
                  }
  
                  foreach ($this->routeMiddleware as $name => $class) {
                      if (method_exists($router, 'middleware')) {
                          $router->middleware($name, $class);
                      } else {
                          $router->aliasMiddleware($name, $class);
                      }
                  }
  
                  foreach ($this->middlewareGroups as $groupName => $classes) {
                      $router->middlewareGroup($groupName, $classes);
                  }
  
                  foreach ($this->prependGroupMiddleware as $group => $class) {
                      $router->prependMiddlewareToGroup($group, $class);
                  }
  
                  foreach ($this->groupMiddleware as $group => $class) {
                      $router->pushMiddlewareToGroup($group, $class);
                  }
              }
          });
  
          $this->onBoot('routing', function (Application $app) {
              foreach ($this->routeFiles as $routeFile) {
                  $this->loadRoutesFrom(path_join($this->resolvePath('routesPath'), str_ensure_right($routeFile, '.php')));
              }
          });
  
          static::refreshRoutes($app);
      }
code: protected function startRoutingPlugin($app)
      {
          $this->requiresPlugins(Paths::class, Resources::class);
          $this->onRegister('routing', function (Application $app) {
              if (PHP_SAPI !== 'cli' || $this->app->runningUnitTests()) {
                  $router = $app->make('router');
                  $kernel = $app->make('Illuminate\Contracts\Http\Kernel');
  
                  foreach ($this->prependMiddleware as $class) {
                      $kernel->prependMiddleware($class);
                  }
  
                  foreach ($this->middleware as $class) {
                      $kernel->pushMiddleware($class);
                  }
  
                  foreach ($this->routeMiddleware as $name => $class) {
                      if (method_exists($router, 'middleware')) {
                          $router->middleware($name, $class);
                      } else {
                          $router->aliasMiddleware($name, $class);
                      }
                  }
  
                  foreach ($this->middlewareGroups as $groupName => $classes) {
                      $router->middlewareGroup($groupName, $classes);
                  }
  
                  foreach ($this->prependGroupMiddleware as $group => $class) {
                      $router->prependMiddlewareToGroup($group, $class);
                  }
  
                  foreach ($this->groupMiddleware as $group => $class) {
                      $router->pushMiddlewareToGroup($group, $class);
                  }
              }
          });
  
          $this->onBoot('routing', function (Application $app) {
              foreach ($this->routeFiles as $routeFile) {
                  $this->loadRoutesFrom(path_join($this->resolvePath('routesPath'), str_ensure_right($routeFile, '.php')));
              }
          });
  
          static::refreshRoutes($app);
      }
code_tokens: protected function startRoutingPlugin ( $ app ) { $ this -> requiresPlugins ( Paths :: class , Resources :: class ) ; $ this -> onRegister ( 'routing' , function ( Application $ app ) { if ( PHP_SAPI !== 'cli' || $ this -> app -> runningUnitTests ( ) ) { $ router = $ app -> make ( 'router' ) ; $ kernel = $ app -> make ( 'Illuminate\Contracts\Http\Kernel' ) ; foreach ( $ this -> prependMiddleware as $ class ) { $ kernel -> prependMiddleware ( $ class ) ; } foreach ( $ this -> middleware as $ class ) { $ kernel -> pushMiddleware ( $ class ) ; } foreach ( $ this -> routeMiddleware as $ name => $ class ) { if ( method_exists ( $ router , 'middleware' ) ) { $ router -> middleware ( $ name , $ class ) ; } else { $ router -> aliasMiddleware ( $ name , $ class ) ; } } foreach ( $ this -> middlewareGroups as $ groupName => $ classes ) { $ router -> middlewareGroup ( $ groupName , $ classes ) ; } foreach ( $ this -> prependGroupMiddleware as $ group => $ class ) { $ router -> prependMiddlewareToGroup ( $ group , $ class ) ; } foreach ( $ this -> groupMiddleware as $ group => $ class ) { $ router -> pushMiddlewareToGroup ( $ group , $ class ) ; } } } ) ; $ this -> onBoot ( 'routing' , function ( Application $ app ) { foreach ( $ this -> routeFiles as $ routeFile ) { $ this -> loadRoutesFrom ( path_join ( $ this -> resolvePath ( 'routesPath' ) , str_ensure_right ( $ routeFile , '.php' ) ) ) ; } } ) ; static :: refreshRoutes ( $ app ) ; }
docstring: startMiddlewarePlugin method.
  
  @param Application $app
docstring_tokens: startMiddlewarePlugin method .