Laravel 5 View 正在从缓存加载,新代码不影响

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/30784375/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 11:46:24  来源:igfitidea点击:

Laravel 5 View is loading from cache and new code not affecting

phplaravellaravel-5laravel-blade

提问by Ariful Haque

I have been working in my Vagrant development environment and the Laravel 5 app is working fine. When I uploaded the app to my DO Ubuntu 14.14 droplet, its loading the View from cache and when I update the view blade template, its not affecting the site.

我一直在我的 Vagrant 开发环境中工作,Laravel 5 应用程序运行良好。当我将应用程序上传到我的 DO Ubuntu 14.14 droplet 时,它从缓存加载视图,当我更新视图刀片模板时,它不会影响站点。

I've searched for solution but didn't found anything. Now sure how to stop caching the view or refresh the cache.

我已经搜索了解决方案,但没有找到任何东西。现在确定如何停止缓存视图或刷新缓存。

Error:

错误:

ErrorException in 61093154cb848bf7f33155b09ac70c93 line 132: Undefined property: Illuminate\Database\Eloquent\Collection::$profile_picture (View: /var/www/demo/property/public/resources/views/user/account/acc.blade.php)

    in 61093154cb848bf7f33155b09ac70c93 line 132
    at CompilerEngine->handleViewException(object(ErrorException), '1') in PhpEngine.php line 43
    at PhpEngine->evaluatePath('/var/www/demo/property/public/storage/framework/views/61093154cb848bf7f33155b09ac70c93', array('__env' => object(Factory), 'app' => object(Application), 'errors' => object(ViewErrorBag), 'page_title' => 'User Account', 'profile' => object(Collection))) in CompilerEngine.php line 57
    at CompilerEngine->get('/var/www/demo/property/public/resources/views/user/account/acc.blade.php', array('__env' => object(Factory), 'app' => object(Application), 'errors' => object(ViewErrorBag), 'page_title' => 'User Account', 'profile' => object(Collection))) in View.php line 136
    at View->getContents() in View.php line 104
    at View->renderContents() in View.php line 78
    at View->render() in Response.php line 44
    at Response->setContent(object(View)) in Response.php line 202
    at Response->__construct(object(View)) in Router.php line 1198
    at Router->prepareResponse(object(Request), object(View)) in Router.php line 702
    at Router->Illuminate\Routing\{closure}(object(Request))
    at call_user_func(object(Closure), object(Request)) in Pipeline.php line 141
    at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Authenticate.php line 47
    at Authenticate->handle(object(Request), object(Closure)) in Pipeline.php line 125
    at Pipeline->Illuminate\Pipeline\{closure}(object(Request))
    at call_user_func(object(Closure), object(Request)) in Pipeline.php line 101
    at Pipeline->then(object(Closure)) in Router.php line 703
    at Router->runRouteWithinStack(object(Route), object(Request)) in Router.php line 670
    at Router->dispatchToRoute(object(Request)) in Router.php line 628
    at Router->dispatch(object(Request)) in Kernel.php line 214
    at Kernel->Illuminate\Foundation\Http\{closure}(object(Request))
    at call_user_func(object(Closure), object(Request)) in Pipeline.php line 141
    at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in VerifyCsrfToken.php line 43
    at VerifyCsrfToken->handle(object(Request), object(Closure)) in VerifyCsrfToken.php line 17
    at VerifyCsrfToken->handle(object(Request), object(Closure)) in Pipeline.php line 125
    at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in ShareErrorsFromSession.php line 55
    at ShareErrorsFromSession->handle(object(Request), object(Closure)) in Pipeline.php line 125
    at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in StartSession.php line 61
    at StartSession->handle(object(Request), object(Closure)) in Pipeline.php line 125
    at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in AddQueuedCookiesToResponse.php line 36
    at AddQueuedCookiesToResponse->handle(object(Request), object(Closure)) in Pipeline.php line 125
    at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in EncryptCookies.php line 40
    at EncryptCookies->handle(object(Request), object(Closure)) in Pipeline.php line 125
    at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in CheckForMaintenanceMode.php line 42
    at CheckForMaintenanceMode->handle(object(Request), object(Closure)) in Pipeline.php line 125
    at Pipeline->Illuminate\Pipeline\{closure}(object(Request))
    at call_user_func(object(Closure), object(Request)) in Pipeline.php line 101
    at Pipeline->then(object(Closure)) in Kernel.php line 115
    at Kernel->sendRequestThroughRouter(object(Request)) in Kernel.php line 84
    at Kernel->handle(object(Request)) in index.php line 53

After the error, I've updated the line 132 but its not affecting. I tried by removing all content from the acc.blade.php file but still I get the error.

错误发生后,我更新了第 132 行,但没有影响。我尝试从 acc.blade.php 文件中删除所有内容,但仍然出现错误。

采纳答案by Kyslik

I made a package (artisan command) for clearing views because it was really annoying to clear them manually.

我制作了一个用于清除视图的包(工匠命令),因为手动清除它们真的很烦人。

https://github.com/Kyslik/view-clear

https://github.com/Kyslik/view-clear

when installed just $ php artisan view:clear

刚安装时 $ php artisan view:clear

If you are using Laravel 5.1.* you don't need this package since it is part of Laravel base commands.

如果你使用 Laravel 5.1.* 你不需要这个包,因为它是 Laravel 基本命令的一部分。



Perhaps browser itself is doing some caching, so use "hard reload" or "hard refresh" using ctrl+f5 (ctrl+r) on windows or shift+command+r on osx.

也许浏览器本身正在做一些缓存,所以在 Windows 上使用 ctrl+f5 (ctrl+r) 或在 osx 上使用 shift+command+r 使用“硬重新加载”或“硬刷新”。