未找到 Laravel 5.1 视图

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

Laravel 5.1 View not found

phplaravellaravel-5bladehomestead

提问by Livewire

this seems to be an issue that pops up every now and then within Laravel. I was writing a CRUD controller with a view to go with it, however upon testing I got the InvalidArgumentException in FileViewFinder.php line 137: View [bookingcrud.index] not founderror. Here is my code:

这似乎是 Laravel 中时不时出现的一个问题。我正在编写一个 CRUD 控制器,目的是为了配合它,但是在测试时我得到了InvalidArgumentException in FileViewFinder.php line 137: View [bookingcrud.index] not found错误。这是我的代码:

routes.php:

路线.php:

Route::resource('bookingcrud', 'BookingsCrudController');

BookingsCrudController.php

BookingsCrudController.php

use uasc\Http\Requests;
use uasc\Http\Requests\CrudCreateRequest;
use uasc\Http\Requests\CrudUpdateRequest;
use uasc\Http\Controllers\Controller;

use Auth;
use DB;
use Illuminate\Pagination\Paginator;

use Illuminate\Http\Request;

class BookingsCrudController extends Controller {

    public function index()
    {
        if (!Auth::check() || Auth::user()->authority < 1) {
            return redirect('/login');
        }

        $raw = "select * from bookings";
        $bookings = DB::select($raw);
        $paginatedBookings = new Paginator($bookings, 1);

        return view('bookingcrud.index')->with('bookings', $paginatedBookings);
    }
}

And a view located in ~/laravel/resources/views/bookingcrud/index.blade.phpNo matter what is in this view file whether its markup from a working view or just the word "cheese" i will always get:

一个视图位于~/laravel/resources/views/bookingcrud/index.blade.php无论这个视图文件中是什么,无论是来自工作视图的标记还是只是“奶酪”这个词,我总是会得到:

InvalidArgumentException in FileViewFinder.php line 140:
View [bookingcrud.index] not found.

I tested the same view in a known working controller and got the same error however I tested a known working view on the same CRUD controller and it worked. I have also tried changing the directory of the view and renaming it but i'll get the same error with the "View [bookingcrud.index]" changing appropriately. I made sure the permissions of the file and directories were full for testing.

我在一个已知的工作控制器中测试了相同的视图并得到了相同的错误但是我在同一个 CRUD 控制器上测试了一个已知的工作视图并且它工作了。我还尝试更改视图的目录并重命名它,但我会在“视图 [bookingcrud.index]”适当更改时遇到相同的错误。我确保文件和目录的权限已满以进行测试。

Since first getting the error I have upgraded to 5.1.1 from 5.0.26 (which is the version the error originated on for me) and ran composer update. Also from looking at threads with the same error I have also ran artisan config:clear

自从第一次收到错误以来,我已从 5.0.26(这是我的错误产生的版本)升级到 5.1.1 并运行 composer update。同样通过查看具有相同错误的线程,我还运行了 artisan config:clear

I am developing on Windows 8.1 with Homestead 2.0.17 deployed with Virtual Box.

我正在 Windows 8.1 上开发 Homestead 2.0.17 和 Virtual Box。

Any help would much appriciated at this point it is doing my head in.

在这一点上,任何帮助都会让我受益匪浅。

采纳答案by Livewire

Turns out I had spelt blade incorrectly, took a second pair of eyes to notice it though.

原来我拼错了blade,虽然我用第二双眼睛注意到了它。

$ ls resources/views/crud/booking/
crud.balde.php  index.balde.php

Was definitely a lesson to always double check the small things when debugging. Thanks for the help.

在调试时总是仔细检查小事情绝对是一个教训。谢谢您的帮助。

回答by Fairuz Sulaiman

Please use terminal

请使用终端

homestead ssh > Press Enter
vagrant@homestead cd /Path_of_Your_Project/
vagrant@homestead:~/Path_of_Your_project php artisan cache:clear
vagrant@homestead:~/Path_of_Your_project php artisan config:cache

Sorry about my English

对不起我的英语

回答by Ronnie Tws

For someone who don't have SSH Access, There are two ways to solve this problem.

对于没有SSH访问权限的人,有两种方法可以解决这个问题。

If you don't have any plugin of default Laravel package, First, Just remove the bootstrap/cache/config.phpto solved the file,

如果你没有任何默认 Laravel 包的插件,首先,只需删除bootstrap/cache/config.php即可解决该文件,

OR

或者

If you have any plugin of default Laravel package, Change all related path mentioned bootstrap/cache/config.phpinto the exact path which allocated the laravel project.

如果您有任何默认 Laravel 包的插件,请将所有提到的bootstrap/cache/config.php相关路径更改为分配 Laravel 项目的确切路径。

回答by Francisco Corrales Morales

Remember that Linux is case sensitive!

请记住,Linux 区分大小写!

I had something like this:

我有这样的事情:

return view('MyView', $data);

And it was working on my environment (Mac OS), but not on the deployment server (Ubuntu)!

它在我的环境 (Mac OS) 上运行,但不在部署服务器 (Ubuntu) 上运行!