当前位置:网站首页>laravel8更新之维护模式改进
laravel8更新之维护模式改进
2020-11-08 13:07:00 【神兵小将】
原文连接:https://www.wjcms.net/archives/laravel8%E6%9B%B4%E6%96%B0%E4%B9%8B%E7%BB%B4%E6%8A%A4%E6%A8%A1%E5%BC%8F%E6%94%B9%E8%BF%9B
对php artisan down命令进行了一些非常漂亮的改进。
在以前的版本中,为了只允许某些人访问该网站,您必须使用白名单功能,如本博文所述:
现在支持预渲染维护模式模板,并且消除了最终用户在维护模式期间遇到错误的机会。但是,为此,必须将以下行添加到您的文件中。这些行应直接放在现有常量定义下:public/index.phpLARAVEL_START
define('LARAVEL_START', microtime(true));
if (file_exists(__DIR__.'/../storage/framework/maintenance.php')) {
require __DIR__.'/../storage/framework/maintenance.php';
}
注:php artisan down --message已被移除
如何创建自定义Laravel维护页面
使用Laravel 8,您可以拥有一个秘密,而不是使用IP白名单。要配置它,您要做的就是:
php artisan down --secret=YOUR_SECRET_HERE
确保YOUR_SECRET_HERE使用安全的弦线更换零件!
然后访问处于维护模式的网站,请访问 你的域名+/YOUR_SECRET_HERE,这将生成一个秘密cookie,使您可以像往常一样浏览该网站!
这是使您的网站处于维护模式的好方法,但是仍然允许某些人可以访问它!
该php artisan down命令的另一个很棒的补充是您可以预渲染维护页面,这样即使您运行composer update最终用户,仍然可以看到维护页面,而不是一些错误。
为此,只需运行:
php artisan down --render="errors::503"
这样,您可以进行广泛的维护,而不必担心用户看到一些奇怪的错误,而不用担心页面看起来友好。
很酷的是,您可以将标志组合在一起。例如,您可以运行以下命令以在显示的页面上添加机密并同时更改状态代码:
php artisan down --render="errors::503" --status=200 --secret=YOUR_SECRET_HERE
版权声明
本文为[神兵小将]所创,转载请带上原文链接,感谢
https://my.oschina.net/u/3380391/blog/4707666
边栏推荐
- 10个常见的软件架构模式
- AQS analysis
- 【Python 1-6】Python教程之——数字
- How to write a resume and project
- Research on WLAN direct connection (peer-to-peer connection or P2P) and cross platform research of IOS
- Rust : 性能测试criterion库
- 软件开发中如何与人协作? | 每日趣闻
- [Python 1-6] Python tutorial 1 -- number
- 笔试面试题目:判断单链表是否有环
- This year's salary is 35W +! Why is the salary of Internet companies getting higher and higher?
猜你喜欢

Share the experience of passing the PMP examination

Shell uses. Net objects to send mail

AQS解析

The network adapter could not establish the connection

Essential for back-end programmers: distributed transaction Basics

笔试面试题目:盛水最多的容器

Top 5 Chinese cloud manufacturers in 2018: Alibaba cloud, Tencent cloud, AWS, telecom, Unicom

Top 5 Chinese cloud manufacturers in 2018: Alibaba cloud, Tencent cloud, AWS, telecom, Unicom

Or talk No.19 | Facebook Dr. Tian Yuandong: black box optimization of hidden action set based on Monte Carlo tree search

在51CTO学院Get到PMP证书
随机推荐
Powershell 使用.Net对象发送邮件
值得一看!EMR弹性低成本离线大数据分析最佳实践(附网盘链接)
Adobe Lightroom /Lr 2021软件安装包(附安装教程)
nat转换的ip跟端口ip不相同的解决方法
Understanding design patterns
一个方案提升Flutter内存利用率
Ali! Visual computing developer's series of manuals (with internet disk link)
用 Python 写出来的进度条,竟如此美妙~
阿里教你深入浅出玩转物联网平台!(附网盘链接)
Win10 terminal + WSL 2 installation and configuration guide, exquisite development experience
Flink from introduction to Zhenxiang (10. Sink data output elasticsearch)
Google's AI model, which can translate 101 languages, is only one more than Facebook
Major changes in Huawei's cloud: Cloud & AI rises to Huawei's fourth largest BG with full fire
[Python 1-6] Python tutorial 1 -- number
Hematemesis! Alibaba Android Development Manual! (Internet disk link attached)
用科技赋能教育创新与重构 华为将教育信息化落到实处
运维人员常用到的 11 款服务器监控工具
Python Gadgets: code conversion
分布式文档存储数据库之MongoDB基础入门
【Python 1-6】Python教程之——数字
