FileViewFinder.php 第 137 行中的 Laravel 5 InvalidArgumentException:未找到视图 [.admin]

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

Laravel 5 InvalidArgumentException in FileViewFinder.php line 137: View [.admin] not found

phplaravellaravel-5

提问by deep singh

This is student.phpand my function for admin:

这是student.php和我的管理员功能:

 public function admin(Request $request){

       if($request->isMethod('get')){
       return \View::make('/admin');
    }
       else
        {

                 $UserData['email'] = Input::get('username');
                 $UserData['password'] = Input::get('password');
                 User::create($UserData);
                 return 'admintest';
                 //return Redirect::to('/view');
         }
   }   

routes.php

路由文件

      Route::match(['get', 'post'], '/admin', 'student@admin');

This is admin form:

这是管理表单:

     {!! Form::open(array('url' => '/admin')) !!}
  <input type="hidden" name="_token" value="{{ csrf_token() }}">


    User Name:<br />
      <input name="username" type="text" id="username" size="40" />
    <br /><br />
    Password:<br />
   <input name="password" type="password" id="password" size="40" />
   <br />
   <br />
   <br />

     <input type="submit" name="button" id="button" value="Log In" />


  {!! Form::close() !!}

Don't know why showing error:

不知道为什么显示错误:

InvalidArgumentException in FileViewFinder.php line 137: View [.] not found

FileViewFinder.php 第 137 行中的 InvalidArgumentException:未找到视图 [.]

采纳答案by Sulthan Allaudeen

A view should an extension .blade.php.

一个视图应该是一个扩展.blade.php

So your file that has the admin form should have the name admin.blade.php

因此,具有管理表单的文件应该具有名称 admin.blade.php

Note :

笔记 :

If you have the view under any sub directory like somefolder/admin.blade.php

如果您在任何子目录下有视图 somefolder/admin.blade.php

Then you should do like this

那你应该这样做

return \View::make('somefolder/admin');

return \View::make('somefolder/admin');

Learn more about templatinghere :)

在此处了解有关模板的更多信息:)

回答by Williem

If you recently deployed you project to your production server or moved the project to another server, do not forget to clear the app cacheby running these commands.

如果您最近将项目部署到生产服务器或将项目移动到另一台服务器,请不要忘记通过运行这些命令来清除应用程序缓存

php artisan cache:clear
php artisan view:clear
php artisan config:cache

it should fix it.

它应该修复它。

Also consider updating your .envfile to match new environment variables.

还要考虑更新您的.env文件以匹配新的环境变量。

回答by goodnesskay

If any of the answers above do not work. why don't you try modifying the name of config.phpproject/bootstrap/cache/config.php to another name like config.php.old it worked for me with laravel 5.3

如果上述任何答案不起作用。你为什么不尝试将config.phpproject/bootstrap/cache/config.php的名称修改为另一个名称,如 config.php.old 它在 laravel 5.3 中对我有用

回答by Oscar David

I had the same problem because I had a backslash \, the solution was change it to slash:

我遇到了同样的问题,因为我有一个反斜杠\,解决方案是将其更改为斜杠:

return \View::make('folder/admin');

回答by user2479930

You don't want to reference your views beginning with a slash.

您不想引用以斜杠开头的视图。

This:

这个:

return \View::make('/admin');

return \View::make('/admin');

Should look like:

应该看起来像:

return \View::make('admin');

return \View::make('admin');

回答by Pankaj Shukla

Please check first that folder is under views folder i.e resources/views/foldername/filename

请先检查该文件夹是否在视图文件夹下,即 resources/views/foldername/filename

then you can test

然后你可以测试

Route::get('route_name', function () {
    return view('foldername.file_name');
});

回答by MrBean

Laravel has an authentication skeleton generator which might have been previously used prior to your current state in your project. I had this error and I was coming from a git clone that had Laravel extra's omitted from sharing good practices.

Laravel 有一个身份验证框架生成器,它可能在您的项目当前状态之前使用过。我遇到了这个错误,而且我来自一个 git 克隆,该克隆在分享良好实践时省略了 Laravel extra。

By reissuing the command

通过重新发出命令

php artisan make:auth

https://laravel.com/docs/5.6/authentication#introduction

https://laravel.com/docs/5.6/authentication#introduction