【问题标题】:After moving to Homestead server laravel cant find view files移动到 Homestead 服务器后,laravel 找不到视图文件
【发布时间】:2019-01-24 18:24:39
【问题描述】:

我最近从 Mac 本地 apache、mysql 设置切换到 Vagrant Laravel/Homestead 服务器。尝试运行我的应用程序时。它给了我以下错误。

View [components.people.feed] not found.

我的饲料方法:

return view('components.people.feed')->with('people', $people);

我的查看目录

resources
-
 views
  -
   components
    -
     people
      -
      feed.blade.php

我的应用在我们的生产服务器上工作。它不返回任何错误。 仅在 Homestead 服务器上运行时。

会不会是宅基地问题?第一次尝试使用它。

提前感谢。

【问题讨论】:

标签: laravel


【解决方案1】:

我不确定它是否会有所帮助,但听起来这也是一个与缓存相关的问题。所以,试试这个:

php artisan view:clear

【讨论】:

  • 好吧,也只是猜测,但是你开发项目的时候有没有修改/config/view.php?它应该有'paths' => [realpath(base_path('resources/views')), ],
  • 不,我没有修改过那个文件。内容相同:'paths' => [realpath(base_path('resources/views')), ],
  • 我试了一下。没有运气(
  • 好的。运行php artisan route:cachephp artisan optimize --force。另外,如果 Homestead 看到您的视图,请尝试连接到 VM 并使用 ls 命令查看:vagrant sshls project/rosources/views/components/people
【解决方案2】:

我遇到了同样的问题,这是视图文件的区分大小写的文件路径/文件名的问题。

【讨论】:

    【解决方案3】:

    清除生产服务器上的缓存解决了我的问题:

    //Clear Cache facade value:
    Route::get('/clear-cache', function() {
        $exitCode = Artisan::call('cache:clear');
        return '<h1>Cache facade value cleared</h1>';
    });
    
    //Route cache:
    Route::get('/route-cache', function() {
        $exitCode = Artisan::call('route:cache');
        return '<h1>Routes cached</h1>';
    });
    
    //Clear Route cache:
    Route::get('/route-clear', function() {
        $exitCode = Artisan::call('route:clear');
        return '<h1>Route cache cleared</h1>';
    });
    
    //Clear View cache:
    Route::get('/view-clear', function() {
        $exitCode = Artisan::call('view:clear');
        return '<h1>View cache cleared</h1>';
    });
    
    //Clear Config cache:
    Route::get('/config-cache', function() {
        $exitCode = Artisan::call('config:cache');
        return '<h1>Clear Config cleared</h1>';
    });
    

    【讨论】:

      猜你喜欢
      • 2016-02-02
      • 2022-01-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多