Laravel 5 维护模式无需工匠即可开启
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/34821095/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Laravel 5 maintenance mode turn on without artisan
提问by zlotte
Is there any possibility to turn on and turn off Laravel 5 maintenance without php artisan up and down commands when my website is being hosted ?
当我的网站被托管时,是否有可能在没有 php artisan up 和 down 命令的情况下打开和关闭 Laravel 5 维护?
What I've done:
我所做的:
Route::get('site/shutdown', function(){
return Artisan::call('down');
});
Route::get('site/live', function(){
return Artisan::call('up');
});
The first route is working fine. But when I call site/live the site still is shuted down. What can cause this problem ?
第一条路线工作正常。但是当我调用 site/live 时,该站点仍然被关闭。什么会导致这个问题?
回答by smartrahat
If your project is already down, you cannot call another function.
如果您的项目已经关闭,则无法调用其他函数。
What happened after you run php artisan down
. It creates a file named down
inside storage/framework
. After running php artisan up
it removes the file.
你跑后发生了什么php artisan down
。它创建一个名为down
inside的文件storage/framework
。运行php artisan up
后删除文件。
You can create the file manually inside storage/framework
. It will down your project. When you want live your project again, just remove the file.
你可以在里面手动创建文件storage/framework
。它会降低你的项目。当您想再次启用您的项目时,只需删除该文件即可。
回答by Szaby
In order to make your site live again using an url, you can create a live.php file which you put in laravel's public folder and then visit http://your.domain/live.php.
为了使用 url 使您的站点再次上线,您可以创建一个 live.php 文件,将其放入 Laravel 的公共文件夹中,然后访问http://your.domain/live.php。
In the live.php file you need something like this: (check your projects directory structure if you don't use the default public folder!)
在 live.php 文件中,您需要这样的内容:(如果您不使用默认的公共文件夹,请检查您的项目目录结构!)
<?php
unlink(dirname(__FILE__) . "/../storage/framework/down");
header("Location: your.domain");
die;
回答by Khairul Hafizi
just put
就放
Artisan::call('up');
without route function.
没有路由功能。
回答by Vahid2015
I think the right answer is missing here.. You could add your route to app/http/middleware/CheckForMaintenanceMode.php
我认为这里缺少正确的答案..您可以将您的路线添加到 app/http/middleware/CheckForMaintenanceMode.php
protected $except = [
//here
];
So It never would be off.
所以它永远不会关闭。
回答by Mohamed Coder
when you run artisan down. site is not available so when try to call up, your IP can't access site. you must call down with your IP exception.
当你让工匠倒下时。站点不可用,所以当尝试调用时,您的 IP 无法访问站点。你必须用你的 IP 例外呼叫。
php artisan down --allow=127.0.0.1 --allow=192.168.0.0/16
or add ::1 to local.
或将 ::1 添加到本地。
to make that in route without command try to save this command in specific one and call it.
要在没有命令的情况下进行路由,请尝试将此命令保存在特定的命令中并调用它。