当前位置:网站首页>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
边栏推荐
- Top 5 Chinese cloud manufacturers in 2018: Alibaba cloud, Tencent cloud, AWS, telecom, Unicom
- 你的云服务器可以用来做什么?云服务器有什么用途?
- 值得一看!EMR弹性低成本离线大数据分析最佳实践(附网盘链接)
- Bccoin tells you: what is the most reliable investment project at the end of the year!
- Top 5 Chinese cloud manufacturers in 2018: Alibaba cloud, Tencent cloud, AWS, telecom, Unicom
- 笔试面试题目:判断单链表是否有环
- 供货紧张!苹果被曝 iPhone 12 电源芯片产能不足
- 入门级!教你小程序开发不求人(附网盘链接)
- 擅长To C的腾讯,如何借腾讯云在这几个行业云市场占有率第一?
- 为什么 Schnorr 签名被誉为比特币 Segwit 后的最大技术更新
猜你喜欢
This year's salary is 35W +! Why is the salary of Internet companies getting higher and higher?
Ali tear off the e-commerce label
The container with the most water
Eight ways to optimize if else code
Introduction to mongodb foundation of distributed document storage database
Istio traffic management -- progress gateway
“他,程序猿,35岁,被劝退”:不要只懂代码,会说话,胜过10倍默默努力
小米、OPPO在欧洲市场继续飙涨,小米更是直逼苹果
On the software of express delivery cabinet and deposit cabinet under Windows
PMP experience sharing
随机推荐
【Python 1-6】Python教程之——数字
Top 5 Chinese cloud manufacturers in 2018: Alibaba cloud, Tencent cloud, AWS, telecom, Unicom
新型存算一体芯片诞生,利好人工智能应用~
最全!阿里巴巴经济体云原生实践!(附网盘链接)
What is SVG?
How to write a resume and project
分布式文档存储数据库之MongoDB基础入门
浅谈单调栈
Python基础语法
Flink: from introduction to Zhenxiang (6. Flink implements UDF function - realizes more fine-grained control flow)
2018中国云厂商TOP5:阿里云、腾讯云、AWS、电信、联通 ...
The container with the most water
Shell uses. Net objects to send mail
金融领域首个开源中文BERT预训练模型,熵简科技推出FinBERT 1.0
C语言I博客作业03
10个常见的软件架构模式
Flink从入门到真香(6、Flink实现UDF函数-实现更细粒度的控制流)
Tencent, which is good at to C, how to take advantage of Tencent's cloud market share in these industries?
On the confirmation of original data assets
擅长To C的腾讯,如何借腾讯云在这几个行业云市场占有率第一?