如何清除服务器上的路由缓存:Laravel 5.2.37
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/37878951/
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
How to clear Route Caching on server: Laravel 5.2.37
提问by Pankaj
This is regarding route cache on localhost
这是关于本地主机上的路由缓存
About Localhost
关于本地主机
I have 2 routes in my route.php file. Both are working fine. No problem in that. I was learning route:clear and route:cache and found a small problem below.
我的 route.php 文件中有 2 条路线。两者都工作正常。没有问题。我在学习 route:clear 和 route:cache 时发现了一个下面的小问题。
if I comment any one route in my route.php file and then run below command
如果我在我的 route.php 文件中评论任何一条路线,然后在命令下面运行
php artisan route:cache
This will keep the route disabled because the route list is in cache now. Now, go to route.php file and try to remove commented route and then try to run that enabled url. still it will show 404 because I need to remove cache by using below command
这将保持路由禁用,因为路由列表现在在缓存中。现在,转到 route.php 文件并尝试删除注释的路由,然后尝试运行该启用的 url。它仍然会显示 404,因为我需要使用以下命令删除缓存
php artisan route:clear
So far everything is understood in localhost. No problem in that.
到目前为止,一切都在 localhost 中得到了理解。没有问题。
After deploying on shared hosting server on godaddy
在godaddy的共享托管服务器上部署后
Question : How can I remove the route cache on server?
问题:如何删除服务器上的路由缓存?
采纳答案by Dees Oomens
If you want to remove the routes cache on your server, remove this file:
如果要删除服务器上的路由缓存,请删除此文件:
bootstrap/cache/routes.php
bootstrap/cache/routes.php
And if you want to update it just run php artisan route:cache
and upload the bootstrap/cache/routes.php
to your server.
如果您想更新它,只需运行php artisan route:cache
并将其上传bootstrap/cache/routes.php
到您的服务器。
回答by Sakil
If you are uploading your files through GIT from your local machine then you can use the same command you are using in your local machine while you are connected to your live server using BASH or something like.You can use this as like you use locally.
如果您从本地机器通过 GIT 上传文件,那么当您使用 BASH 或类似方法连接到实时服务器时,您可以使用在本地机器上使用的相同命令。您可以像在本地使用一样使用它。
php artisan cache:clear
php artisan route:cache
It should work.
它应该工作。
回答by Amitesh
For your case solution is :
对于您的案例解决方案是:
php artisan cache:clear
php artisan route:cache
Optimizing Route Loading is a must on production :
优化路由加载是生产中必须的:
If you are building a large application with many routes, you should make sure that you are running the route:cache Artisan command during your deployment process:
如果您正在构建具有许多路由的大型应用程序,则应确保在部署过程中运行 route:cache Artisan 命令:
php artisan route:cache
This command reduces all of your route registrations into a single method call within a cached file, improving the performance of route registration when registering hundreds of routes.
此命令将所有路由注册减少到缓存文件中的单个方法调用中,从而在注册数百条路由时提高路由注册的性能。
Since this feature uses PHP serialization, you may only cache the routes for applications that exclusively use controller based routes. PHP is not able to serialize Closures.
由于此功能使用 PHP 序列化,因此您只能缓存专门使用基于控制器的路由的应用程序的路由。PHP 无法序列化闭包。
Laravel 5 clear cache from route, view, config and all cache data from application
Laravel 5 从路由、视图、配置和应用程序的所有缓存数据中清除缓存
I would like to share my experience and solution. when i was working on my laravel e commerce website with gitlab. I was fetching one issue suddenly my view cache with error during development. i did try lot to refresh and something other but i can't see any more change in my view, but at last I did resolve my problem using laravel command so, let's see i added several command for clear cache from view, route, config etc.
我想分享我的经验和解决方案。当我使用 gitlab 在我的 laravel 电子商务网站上工作时。我在开发过程中突然获取了一个问题,我的视图缓存出错。我确实尝试了很多刷新和其他内容,但我的视图中看不到任何更多变化,但最后我确实使用 laravel 命令解决了我的问题,让我们看看我添加了几个命令来清除视图、路由、配置中的缓存等等。
Reoptimized class loader:
重新优化的类加载器:
php artisan optimize
Clear Cache facade value:
清除缓存外观值:
php artisan cache:clear
Clear Route cache:
清除路由缓存:
php artisan route:cache
Clear View cache:
清除视图缓存:
php artisan view:clear
Clear Config cache:
清除配置缓存:
php artisan config:cache
回答by Bakhtiar
you can define a route in web.php
你可以在 web.php 中定义一个路由
Route::get('/clear/route', 'ConfigController@clearRoute');
and make ConfigController.php like this
并使 ConfigController.php 像这样
class ConfigController extends Controller
{
public function clearRoute()
{
\Artisan::call('route:clear');
}
}
and go to that route on server example http://your-domain/clear/route
并转到服务器示例上的该路线 http://your-domain/clear/route