當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Router::middleware方法代碼示例

本文整理匯總了PHP中Illuminate\Routing\Router::middleware方法的典型用法代碼示例。如果您正苦於以下問題:PHP Router::middleware方法的具體用法?PHP Router::middleware怎麽用?PHP Router::middleware使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Illuminate\Routing\Router的用法示例。


在下文中一共展示了Router::middleware方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: boot

 /**
  * Register routes, translations, views and publishers.
  *
  * @return void
  */
 public function boot(\Illuminate\Routing\Router $router)
 {
     Config::set('auth.model', 'Askedio\\Laravelcp\\Models\\User');
     Config::set('auth.password.email', 'lcp::emails.password');
     $router->middleware('auth', 'Askedio\\Laravelcp\\Http\\Middleware\\Authenticate');
     $router->middleware('auth.basic', 'Illuminate\\Auth\\Middleware\\AuthenticateWithBasicAuth');
     $router->middleware('guest', 'Askedio\\Laravelcp\\Http\\Middleware\\RedirectIfAuthenticated');
     $router->middleware('role', 'Askedio\\Laravelcp\\Http\\Middleware\\VerifyRole');
     $router->middleware('permission', 'Askedio\\Laravelcp\\Http\\Middleware\\VerifyPermission');
     $loader = \Illuminate\Foundation\AliasLoader::getInstance();
     $loader->alias('Nav', 'Askedio\\Laravelcp\\Helpers\\NavigationHelper');
     $loader->alias('Hook', 'Askedio\\Laravelcp\\Helpers\\HookHelper');
     $loader->alias('Search', 'Askedio\\Laravelcp\\Helpers\\SearchHelper');
     NavigationHelper::Initialize();
     HookHelper::Initialize();
     SearchHelper::Initialize();
     if (!$this->app->routesAreCached()) {
         require realpath(__DIR__ . '/../Http/routes.php');
     }
     $this->loadTranslationsFrom(realpath(__DIR__ . '/../Resources/Lang'), 'lcp');
     $this->loadViewsFrom(realpath(__DIR__ . '/../Resources/Views'), 'lcp');
     NavigationHelper::Add(['nav' => 'main', 'sort' => '0', 'link' => url('/dashboard'), 'title' => trans('lcp::nav.dashboard'), 'icon' => 'fa-dashboard']);
     $this->publishes([realpath(__DIR__ . '/../Resources/Views') => base_path('resources/views/vendor/askedio/laravelcp')], 'views');
     $this->publishes([realpath(__DIR__ . '/../Resources/Assets') => public_path('assets')], 'public');
     $this->publishes([realpath(__DIR__ . '/../Resources/Config') => config_path('')], 'config');
     $this->publishes([realpath(__DIR__ . '/../Database/Migrations') => database_path('migrations')], 'migrations');
     $this->publishes([realpath(__DIR__ . '/../Database/Seeds') => database_path('seeds')], 'seeds');
 }
開發者ID:askedio,項目名稱:laravelcp,代碼行數:33,代碼來源:LaravelcpServiceProvider.php

示例2: boot

 /**
  * Perform post-registration booting of services.
  *
  * @return void
  */
 public function boot(Router $router)
 {
     $router->middleware('roles', \App\Http\Middleware\HasRole::class);
     $router->middleware('admin', \App\Http\Middleware\AdminMiddleware::class);
     if (!$this->app->routesAreCached()) {
         require __DIR__ . '/Http/routes.php';
     }
     $configFiles = ['acl'];
     foreach ($configFiles as $config) {
         $this->mergeConfigFrom(__DIR__ . "/config/{$config}.php", 'acl');
     }
     $this->loadTranslationsFrom(__DIR__ . '/resources/lang', 'acl');
     $this->loadViewsFrom(__DIR__ . '/resources/views', 'acl');
     //Publish middleware
     $this->publishes([__DIR__ . '/Middleware/' => app_path('Http/Middleware')]);
     //Publish providers
     $this->publishes([__DIR__ . '/Providers/' => app_path('Providers')]);
     //Publish views
     $this->publishes([__DIR__ . '/resources/views' => resource_path('views')], 'views');
     //Publish translations
     $this->publishes([__DIR__ . '/resources/lang/' => resource_path('lang/')], 'translations');
     // Publish a config file
     $this->publishes([__DIR__ . '/config/acl.php' => config_path('acl.php')], 'config');
     //Publish migrations
     $this->publishes([__DIR__ . '/database/migrations' => database_path('migrations'), __DIR__ . '/database/seeds' => database_path('seeds')], 'migrations');
     $this->publishes([__DIR__ . '/assets/bower_components/AdminLTE/' => public_path('/assets/bower_components/AdminLTE/')], 'public');
     $this->publishes([__DIR__ . '/Http/Controllers/Auth/' => app_path('/Http/Controllers/Auth/'), __DIR__ . '/Http/Controllers/Admin/' => app_path('/Http/Controllers/Admin/')], 'controllers');
     $this->publishes([__DIR__ . '/Models/Admin/' => app_path()], 'models');
 }
開發者ID:meccado,項目名稱:acl-admin-control-panel,代碼行數:34,代碼來源:AclAdminControlPanelServiceProvider.php

示例3: boot

 /**
  * @param Router $router
  */
 public function boot(Router $router)
 {
     $router->middleware(HalApiETagMiddleware::NAME, HalApiETagMiddleware::class);
     $router->middleware(HalApiCacheMiddleware::NAME, HalApiCacheMiddleware::class);
     $this->app->singleton(RouteHelper::class, function () use($router) {
         return new RouteHelper($router);
     });
 }
開發者ID:jarischaefer,項目名稱:hal-api,代碼行數:11,代碼來源:HalApiServiceProvider.php

示例4: registerMiddleware

 /**
  * Register all the Flare Provided Middleware and Middleware Groups.
  *
  * We define flarebase rather than extend an existing middleware stack
  * since it is possible that a user has amended the default middleware 
  * of their application in a way that could break Flare.
  * 
  * @param Router $router
  */
 protected function registerMiddleware(Router $router)
 {
     $router->middleware('flareauthenticate', \LaravelFlare\Flare\Http\Middleware\FlareAuthenticate::class);
     $router->middleware('checkmodelfound', \LaravelFlare\Flare\Http\Middleware\CheckModelFound::class);
     $router->middleware('checkpermissions', \LaravelFlare\Flare\Http\Middleware\CheckPermissions::class);
     $router->middlewareGroup('flarebase', [\Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class, \Illuminate\View\Middleware\ShareErrorsFromSession::class, \App\Http\Middleware\VerifyCsrfToken::class, \App\Http\Middleware\EncryptCookies::class]);
     $router->middlewareGroup('flare', ['web', 'flarebase', 'flareauthenticate', 'checkpermissions']);
 }
開發者ID:laravelflare,項目名稱:flare,代碼行數:17,代碼來源:RouteServiceProvider.php

示例5: boot

 /**
  * Bootstrap the application services.
  *
  * @return void
  */
 public function boot(Router $router)
 {
     include_once __DIR__ . '/Http/routes.php';
     $this->loadViewsFrom(__DIR__ . '/views', 'lui');
     $this->publishes([__DIR__ . '/database/migrations/2016_08_01_000001_create_demo_table.php' => base_path('database/migrations/2016_08_01_000000_create_demo_table.php')]);
     $router->middleware('luiAuth', \Luivel\Lui\Http\Middleware\luiAuth::class);
     $router->middleware('luiGuest', \Luivel\Lui\Http\Middleware\luiGuest::class);
 }
開發者ID:luivel,項目名稱:lui,代碼行數:13,代碼來源:LuiServiceProvider.php

示例6: boot

 /**
  * Define your route model bindings, pattern filters, etc.
  *
  * @param  \Illuminate\Routing\Router  $router
  * @return void
  */
 public function boot(Router $router)
 {
     $router->middleware('oauth', 'LucaDegasperi\\OAuth2Server\\Middleware\\OAuthMiddleware');
     $router->middleware('oauth-user', 'Ruysu\\Core\\Http\\Middleware\\OAuthUser');
     $router->middleware('oauth-owner', 'LucaDegasperi\\OAuth2Server\\Middleware\\OAuthOwnerMiddleware');
     $router->middleware('check-authorization-params', 'LucaDegasperi\\OAuth2Server\\Middleware\\CheckAuthCodeRequestMiddleware');
     parent::boot($router);
 }
開發者ID:ruysu,項目名稱:laravel-core,代碼行數:14,代碼來源:RouteServiceProvider.php

示例7: boot

 /**
  * Bootstrap the application events.
  *
  * @param Router $router
  */
 public function boot(Router $router)
 {
     $router->middleware('maintenance.not-auth', NotAuthMiddleware::class);
     $router->middleware('maintenance.auth', AuthMiddleware::class);
     $router->middleware('maintenance.permission', PermissionMiddleware::class);
     $this->bootPublishable();
     $this->bootLoadable();
     $this->bootRequiredFiles();
 }
開發者ID:redknitin,項目名稱:maintenance,代碼行數:14,代碼來源:MaintenanceServiceProvider.php

示例8: boot

 /**
  * Define your module's route model bindings, pattern filters, etc.
  *
  * @param  \Illuminate\Routing\Router $router
  * @return void
  */
 public function boot(Router $router)
 {
     $this->initAssets();
     $router->middleware('authenticate', \App\Modules\VergoBase\Http\Middleware\Authenticate::class);
     $router->middleware('AdminAuth', \App\Modules\VergoBase\Http\Middleware\AdminAuth::class);
     $router->middleware('AdminAuthenticate', \App\Modules\VergoBase\Http\Middleware\AdminAuthenticate::class);
     $router->middlewareGroup('webAdmin', [\App\Http\Middleware\EncryptCookies::class, \Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class, \Illuminate\Session\Middleware\StartSession::class, \Illuminate\View\Middleware\ShareErrorsFromSession::class]);
     parent::boot($router);
 }
開發者ID:Golars,項目名稱:Naissance_Laravel,代碼行數:15,代碼來源:RouteServiceProvider.php

示例9: boot

 public function boot(Router $router)
 {
     // Register Middleware
     $router->middleware('spamguard', Middleware\SpamGuard::class);
     $router->middleware('spam_honeypot', Middleware\SpamHoneypot::class);
     $router->middleware('spam_timer', Middleware\SpamTimer::class);
     $router->middleware('spam_recaptcha', Middleware\SpamRecaptcha::class);
     $this->publishes([__DIR__ . '/../../config/spamguard.php' => config_path('spamguard.php')], 'config');
 }
開發者ID:ryanwinchester,項目名稱:laravel-spamguard,代碼行數:9,代碼來源:SpamGuardServiceProvider.php

示例10: boot

 /**
  * Define your route model bindings, pattern filters, etc.
  *
  * @param  \Illuminate\Routing\Router $router
  *
  * @return void
  */
 public function boot(Router $router)
 {
     $router->middleware('soda.main', Cms::class);
     $router->middleware('soda.auth', Authenticate::class);
     $router->middleware('role', EntrustRole::class);
     $router->middleware('permission', EntrustPermission::class);
     $router->middleware('ability', EntrustAbility::class);
     parent::boot($router);
 }
開發者ID:sodacms,項目名稱:sodacms,代碼行數:16,代碼來源:RouteServiceProvider.php

示例11: setupRoutes

 /**
  * Define the routes for the application.
  *
  * @param  \Illuminate\Routing\Router $router
  * @return void
  */
 public function setupRoutes(Router $router)
 {
     // routes
     if (!$this->app->routesAreCached()) {
         require __DIR__ . '/Http/routes.php';
     }
     // middleware
     $router->middleware('guest_user', 'Ax2to\\LaravelUser\\Http\\Middleware\\RedirectIfAuthenticated');
     $router->middleware('auth_user', 'Ax2to\\LaravelUser\\Http\\Middleware\\Authenticate');
 }
開發者ID:ax2to,項目名稱:laravel-user,代碼行數:16,代碼來源:LaravelUserServiceProvider.php

示例12: boot

 /**
  * Register routes, translations, views and publishers.
  *
  * @return void
  */
 public function boot(Router $router)
 {
     $this->loadTranslationsFrom(__DIR__ . '/../lang', 'jsonapi');
     $this->publishes([__DIR__ . '/../lang' => resource_path('lang/vendor/jsonapi'), __DIR__ . '/../config/jsonapi.php' => config_path('jsonapi.php')]);
     $router->middleware('jsonapi', \Askedio\Laravel5ApiController\Http\Middleware\JsonApiMiddleware::class);
     $router->middleware('jsonapi.auth.basic', \Askedio\Laravel5ApiController\Http\Middleware\Auth\JsonApiAuthBasicMiddleware::class);
     response()->macro('jsonapi', function ($code, $value) {
         $apiResponse = new \Askedio\Laravel5ApiController\Http\Responses\ApiResponse();
         return $apiResponse->jsonapi($code, $value);
     });
 }
開發者ID:askedio,項目名稱:laravel-cruddy,代碼行數:16,代碼來源:GenericServiceProvider.php

示例13: boot

 /**
  * Bootstrap the application events.
  *
  * @return void
  */
 public function boot()
 {
     $this->router->middleware('anavel.auth', Authenticate::class);
     include __DIR__ . '/Http/routes.php';
     $this->loadViewsFrom(__DIR__ . '/../views', 'anavel');
     $this->loadTranslationsFrom(__DIR__ . '/../lang', 'anavel');
     $this->publishes([__DIR__ . '/../config/anavel.php' => config_path('anavel.php')], 'config');
     $this->publishes([__DIR__ . '/../public/bootstrap' => public_path('vendor/anavel/bootstrap'), __DIR__ . '/../public/dist' => public_path('vendor/anavel/dist'), __DIR__ . '/../public/plugins' => public_path('vendor/anavel/plugins')], 'assets');
     $anavel = $this->app->make('Anavel\\Foundation\\Contracts\\Anavel');
     $anavel->boot();
 }
開發者ID:anavel,項目名稱:foundation,代碼行數:16,代碼來源:AnavelServiceProvider.php

示例14: boot

 /**
  * Register the service provider.
  * @param Router $router \Illuminate\Contracts\Http\Kernel
  */
 public function boot(Router $router)
 {
     $this->loadViewsFrom(__DIR__ . '/Base/Views', 'backend');
     $this->bootBackend();
     $router->middleware('backend.guest', 'Darryldecode\\Backend\\Base\\Middleware\\RedirectIfAuthenticated');
     $router->middleware('backend.authenticated', 'Darryldecode\\Backend\\Base\\Middleware\\Authenticate');
     $this->publishes([__DIR__ . '/Public/backend/cb' => public_path('darryldecode/backend/cb'), __DIR__ . '/Public/backend/vendor' => public_path('darryldecode/backend/vendor')], 'public');
     $this->publishes([__DIR__ . '/Config' => config_path('backend')], 'config');
     $this->publishes([__DIR__ . '/Database/Migrations' => database_path('migrations'), __DIR__ . '/Database/Seeders' => database_path('seeds')], 'migrations');
     $this->publishes([__DIR__ . '/Components/Auth/Views' => base_path('resources/views/backend/auth')], 'views');
 }
開發者ID:darryldecode,項目名稱:laravelbackend,代碼行數:15,代碼來源:BackendServiceProvider.php

示例15: routerize

 public function routerize(Router $router)
 {
     // Route for the admin controllers
     $router->middleware('admin', 'Mkny\\Cinimod\\Middleware\\Admin');
     $router->middleware('site', 'Mkny\\Cinimod\\Middleware\\Site');
     $router->group(['namespace' => $this->namespace], function ($router) {
         require mkny_path('\\Cinimod\\Controllers\\routes.php');
         // require mkny_path('\Cinimod\Controllers\routes.php');
     });
     // $this->routeResolver($router);
 }
開發者ID:mkny,項目名稱:cinimod,代碼行數:11,代碼來源:CinimodServiceProvider.php


注:本文中的Illuminate\Routing\Router::middleware方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。