首页 > 其他分享 >laravel:路由组(10.27.0)

laravel:路由组(10.27.0)

时间:2023-10-23 09:04:30浏览次数:42  
标签:laravel web HEAD GET 10.27 ignition NewsController news 路由

一,相关文档:

https://learnku.com/docs/laravel/10.x/routing/14845

二,查看所有注册的路由

1,查看路由:

liuhongdi@lhdpc:/data/laravel/dignews$ php artisan route:list

  GET|HEAD   / ............................................................................................................................................................... 
  POST       _ignition/execute-solution ........................................................ ignition.executeSolution › Spatie\LaravelIgnition › ExecuteSolutionController
  GET|HEAD   _ignition/health-check .................................................................... ignition.healthCheck › Spatie\LaravelIgnition › HealthCheckController
  POST       _ignition/update-config ................................................................. ignition.updateConfig › Spatie\LaravelIgnition › UpdateConfigController
  GET|HEAD   api/user ........................................................................................................................................................ 
  GET|HEAD   container/test .................................................................................................................................................. 
  GET|HEAD   news/cache ................................................................................................................................. NewsController@cache
  GET|HEAD   news/home ................................................................................................................................... NewsController@home
  GET|HEAD   news/homejson ........................................................................................................................... NewsController@homejson
  GET|HEAD   news/list ................................................................................................................................... NewsController@list
  GET|HEAD   news/log ..................................................................................................................................... NewsController@log
  GET|HEAD   news/req ..................................................................................................................................... NewsController@req
  GET|HEAD   news/res ..................................................................................................................................... NewsController@res
  GET|HEAD   news/trans ................................................................................................................................. NewsController@trans
  GET|HEAD   sanctum/csrf-cookie ........................................................................... sanctum.csrf-cookie › Laravel\Sanctum › CsrfCookieController@show
  GET|HEAD   {fallbackPlaceholder} ...........................................................................................................................................

2,加-v,查看路由同时显示用到的中间件:

liuhongdi@lhdpc:/data/laravel/dignews$ php artisan route:list -v

  GET|HEAD   / ............................................................................................................................................................... 
             ⇂ web
  POST       _ignition/execute-solution ........................................................ ignition.executeSolution › Spatie\LaravelIgnition › ExecuteSolutionController
             ⇂ Spatie\LaravelIgnition\Http\Middleware\RunnableSolutionsEnabled
  GET|HEAD   _ignition/health-check .................................................................... ignition.healthCheck › Spatie\LaravelIgnition › HealthCheckController
             ⇂ Spatie\LaravelIgnition\Http\Middleware\RunnableSolutionsEnabled
  POST       _ignition/update-config ................................................................. ignition.updateConfig › Spatie\LaravelIgnition › UpdateConfigController
             ⇂ Spatie\LaravelIgnition\Http\Middleware\RunnableSolutionsEnabled
  GET|HEAD   api/user ........................................................................................................................................................ 
             ⇂ api
             ⇂ App\Http\Middleware\Authenticate:sanctum
  GET|HEAD   container/test .................................................................................................................................................. 
             ⇂ web
  GET|HEAD   news/cache ................................................................................................................................. NewsController@cache
             ⇂ web
  GET|HEAD   news/home ................................................................................................................................... NewsController@home
             ⇂ web
  GET|HEAD   news/homejson ........................................................................................................................... NewsController@homejson
             ⇂ web
  GET|HEAD   news/list ................................................................................................................................... NewsController@list
             ⇂ web
  GET|HEAD   news/log ..................................................................................................................................... NewsController@log
             ⇂ web
  GET|HEAD   news/req ..................................................................................................................................... NewsController@req
             ⇂ web
             ⇂ App\Http\Middleware\CheckIp
  GET|HEAD   news/res ..................................................................................................................................... NewsController@res
             ⇂ web
  GET|HEAD   news/trans ................................................................................................................................. NewsController@trans
             ⇂ web
  GET|HEAD   sanctum/csrf-cookie ........................................................................... sanctum.csrf-cookie › Laravel\Sanctum › CsrfCookieController@show
             ⇂ web
  GET|HEAD   {fallbackPlaceholder} ........................................................................................................................................... 
             ⇂ web

说明:刘宏缔的架构森林—专注it技术的博客,
网站:https://blog.imgtouch.com
原文: https://blog.imgtouch.com/index.php/2023/10/22/laravel-lu-you-zu-10-27/
代码: https://github.com/liuhongdi/ 或 https://gitee.com/liuhongdi
说明:作者:刘宏缔 邮箱: [email protected]

三,使用路由组

1,基于controller分组:

Route::controller(NewsController::class)->group(function () {
    Route::get('/news/home', 'home');
    Route::get('/news/homejson', 'homejson');
});

2,基于前缀分组

Route::prefix('news')->group(function () {
    Route::get('/home', [NewsController::class,'home']);
    Route::get('/list', [NewsController::class,'list']);
});

3,基于路由中间件

Route::middleware(['first', 'second'])->group(function () {
    Route::get('/', function () {
        // 使用第一个和第二个中间件。。。
    });
    Route::get('/user/profile', function () {
        // 使用第一个和第二个中间件。。。
    });
});

四,查看laravel框架的版本:

liuhongdi@lhdpc:/data/laravel/dignews$ php artisan --version
Laravel Framework 10.27.0

标签:laravel,web,HEAD,GET,10.27,ignition,NewsController,news,路由
From: https://www.cnblogs.com/architectforest/p/17781571.html

相关文章

  • laravel:blade模板(10.27.0)
    一,相关文档:https://learnku.com/docs/laravel/10.x/blade/14852二,创建controller和view1,创建controllerliuhongdi@lhdpc:/data/laravel/dignews$phpartisanmake:controllerCommentController   INFO  Controller[app/Http/Controllers/CommentController.php......
  • 单臂路由与三层交换机
    目录1.单臂路由1.1为什么用单臂路由?1.2什么是单臂路由?1.3单臂路由的工作原理1.4单臂路由的缺点1.5ensp配置单臂路由实验1.5.1常用配置1.5.2实验步骤2.三层交换机2.1为什么用三层交换机?2.2三层交换机的工作原理2.3eNSP配置三层交换机实验2.3.1常用配置2.3.2实验步骤......
  • 路由策略
    路由控制实现的三种方式: 控制路由的发布:通过路由策略对发布的路由进行过滤,只发布满足条件的路由。 控制路由的接收:通过路由策略对接收的路由进行过滤,只接收满足条件的路由。 控制路由的引入:通过路由策略控制从其他路由协议引入的路由条目,只有满足条件的路由才会被引入。路由匹配......
  • 路由
           ......
  • 路由部署基础
    Nginx路由部署Nginx文件目录build编译Vue项目编译结果放到nginx的html目录下启动nginx,config可以更改占用的端口Tomcat......
  • laravel:服务容器(10.27.0)
    一,相关文档:https://learnku.com/docs/laravel/10.x/container/14842二,php代码:假设我们有两种商品:虚拟商品如账号,实体商品如手办需要销售1,App\extend\mall\GoodsInterface.php1234567<?phpnamespaceApp\extend\mall;//接口interfaceGoodsInterfa......
  • laravel:服务提供者(10.27.0)
    一,相关文档:https://learnku.com/docs/laravel/10.x/providers/14843二,php代码:1,业务代码:App\extend\mall\GoodsInterface.php1234567<?phpnamespaceApp\extend\mall;//接口interfaceGoodsInterface{    publicfunctionsale();}......
  • laravel:捕捉异常记录到日志(10.27.0)
    一,相关文档:https://learnku.com/docs/laravel/10.x/errors/14857#9e8f93二,php代码:1,代码:12345678910111213141516171819202122232425262728classNewsControllerextendsController{    //启用事务    publicfuncti......
  • laravel:定时任务(10.27.0)
    一,相关的文档:https://learnku.com/docs/laravel/10.x/scheduling/14875二,php代码:1,创建command:liuhongdi@lhdpc:/data/laravel/dignews$phpartisanmake:commandOrderStatus   INFO  Consolecommand[app/Console/Commands/OrderStatus.php]createdsucces......
  • laravel:使用tinker(10.27.0)
    一,启动与退出:liuhongdi@lhdpc:/data/laravel/dignews$phpartisantinkerPsyShellv0.11.22(PHP8.1.1—cli)byJustinHileman>exit   INFO  Goodbye.二,查询数据liuhongdi@lhdpc:/data/laravel/dignews$phpartisantinkerPsyShellv0.11.22(PHP8.1.......