laravel运行方式图解:处理csrf、路由配置

2022-02-1421:13:58后端程序开发Comments1,875 views字数 783阅读模式

命令行:文章源自菜鸟学院-https://www.cainiaoxueyuan.com/bc/23205.html

laravel运行方式图解:处理csrf、路由配置

apache设置虚拟主机:文章源自菜鸟学院-https://www.cainiaoxueyuan.com/bc/23205.html

或者通过LAMP的方式设置,文章源自菜鸟学院-https://www.cainiaoxueyuan.com/bc/23205.html

项目目录是根目录/public文章源自菜鸟学院-https://www.cainiaoxueyuan.com/bc/23205.html

CSRF:文章源自菜鸟学院-https://www.cainiaoxueyuan.com/bc/23205.html

laravel运行方式图解:处理csrf、路由配置
laravel运行方式图解:处理csrf、路由配置

laravel处理scrf:文章源自菜鸟学院-https://www.cainiaoxueyuan.com/bc/23205.html

laravel运行方式图解:处理csrf、路由配置

使用session,是针对每台机器的,互相隔离的。文章源自菜鸟学院-https://www.cainiaoxueyuan.com/bc/23205.html

laravel的csrf的文件路径,文章源自菜鸟学院-https://www.cainiaoxueyuan.com/bc/23205.html

web.php网站的路由入口,默认有csrf验证,网站需要防这个文章源自菜鸟学院-https://www.cainiaoxueyuan.com/bc/23205.html

laravel运行方式图解:处理csrf、路由配置

api.php的api接口入口,没有csrf验证,接口使用access_token之类的加密验证,因为接口没法给session,是第三方网址。文章源自菜鸟学院-https://www.cainiaoxueyuan.com/bc/23205.html

laravel运行方式图解:处理csrf、路由配置

排除指定路由不进行csrf文章源自菜鸟学院-https://www.cainiaoxueyuan.com/bc/23205.html

laravel运行方式图解:处理csrf、路由配置
laravel运行方式图解:处理csrf、路由配置
laravel运行方式图解:处理csrf、路由配置

路由文件地址文章源自菜鸟学院-https://www.cainiaoxueyuan.com/bc/23205.html

laravel运行方式图解:处理csrf、路由配置

laravel的4种基础路由的定义:文章源自菜鸟学院-https://www.cainiaoxueyuan.com/bc/23205.html

get,post,put,delete文章源自菜鸟学院-https://www.cainiaoxueyuan.com/bc/23205.html

laravel运行方式图解:处理csrf、路由配置
laravel运行方式图解:处理csrf、路由配置
laravel运行方式图解:处理csrf、路由配置

其它路由的定义:文章源自菜鸟学院-https://www.cainiaoxueyuan.com/bc/23205.html

laravel运行方式图解:处理csrf、路由配置

any方式,不安全文章源自菜鸟学院-https://www.cainiaoxueyuan.com/bc/23205.html

laravel运行方式图解:处理csrf、路由配置

路由参数:文章源自菜鸟学院-https://www.cainiaoxueyuan.com/bc/23205.html

laravel运行方式图解:处理csrf、路由配置

必填:文章源自菜鸟学院-https://www.cainiaoxueyuan.com/bc/23205.html

Route::get("/detail/{id}",function($id){文章源自菜鸟学院-https://www.cainiaoxueyuan.com/bc/23205.html

echo $id;文章源自菜鸟学院-https://www.cainiaoxueyuan.com/bc/23205.html

});文章源自菜鸟学院-https://www.cainiaoxueyuan.com/bc/23205.html

可选:文章源自菜鸟学院-https://www.cainiaoxueyuan.com/bc/23205.html

Route::get("/detail/{id?}",function($id = 0){文章源自菜鸟学院-https://www.cainiaoxueyuan.com/bc/23205.html

echo $id;文章源自菜鸟学院-https://www.cainiaoxueyuan.com/bc/23205.html

});文章源自菜鸟学院-https://www.cainiaoxueyuan.com/bc/23205.html

参数限制,正则:文章源自菜鸟学院-https://www.cainiaoxueyuan.com/bc/23205.html

Route::get("/detail/{id}",function($id){文章源自菜鸟学院-https://www.cainiaoxueyuan.com/bc/23205.html

echo $id;文章源自菜鸟学院-https://www.cainiaoxueyuan.com/bc/23205.html

})->where(['id'=>'d+']);文章源自菜鸟学院-https://www.cainiaoxueyuan.com/bc/23205.html

PHP7新增的特性,类型声明:文章源自菜鸟学院-https://www.cainiaoxueyuan.com/bc/23205.html

参数类型可以限制为整型,文章源自菜鸟学院-https://www.cainiaoxueyuan.com/bc/23205.html

Route::get("/detail/{id}",function(int $id){文章源自菜鸟学院-https://www.cainiaoxueyuan.com/bc/23205.html

echo $id;文章源自菜鸟学院-https://www.cainiaoxueyuan.com/bc/23205.html

})->where(['id'=>'d+']);文章源自菜鸟学院-https://www.cainiaoxueyuan.com/bc/23205.html

路由别名:文章源自菜鸟学院-https://www.cainiaoxueyuan.com/bc/23205.html

laravel运行方式图解:处理csrf、路由配置
laravel运行方式图解:处理csrf、路由配置

路由分组之路由前缀:文章源自菜鸟学院-https://www.cainiaoxueyuan.com/bc/23205.html

laravel运行方式图解:处理csrf、路由配置

Route::group(['prefix'=>'admin'],function(){文章源自菜鸟学院-https://www.cainiaoxueyuan.com/bc/23205.html

Route::get('login',function(){文章源自菜鸟学院-https://www.cainiaoxueyuan.com/bc/23205.html

return 'admin/login';文章源自菜鸟学院-https://www.cainiaoxueyuan.com/bc/23205.html

});文章源自菜鸟学院-https://www.cainiaoxueyuan.com/bc/23205.html

Route::get('logout',function(){文章源自菜鸟学院-https://www.cainiaoxueyuan.com/bc/23205.html

return 'admin/logout';文章源自菜鸟学院-https://www.cainiaoxueyuan.com/bc/23205.html

});文章源自菜鸟学院-https://www.cainiaoxueyuan.com/bc/23205.html

});文章源自菜鸟学院-https://www.cainiaoxueyuan.com/bc/23205.html

laravel运行方式图解:处理csrf、路由配置
laravel运行方式图解:处理csrf、路由配置

查看定义好的路由命令:文章源自菜鸟学院-https://www.cainiaoxueyuan.com/bc/23205.html

php artisan route:list文章源自菜鸟学院-https://www.cainiaoxueyuan.com/bc/23205.html

laravel运行方式图解:处理csrf、路由配置
文章源自菜鸟学院-https://www.cainiaoxueyuan.com/bc/23205.html
  • 本站内容整理自互联网,仅提供信息存储空间服务,以方便学习之用。如对文章、图片、字体等版权有疑问,请在下方留言,管理员看到后,将第一时间进行处理。
  • 转载请务必保留本文链接:https://www.cainiaoxueyuan.com/bc/23205.html

Comment

匿名网友 填写信息

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定