【问题标题】:Class 'App\Http\Controllers\View' not found找不到类“App\Http\Controllers\View”
【发布时间】:2018-05-02 22:04:50
【问题描述】:

我是 Laravel 的新手。我的观点不适合控制器为什么它是。 我的观点 : `

<div class="imgcontainer">

    <img src="img/img_avatar2.png" alt="Avatar" class="avatar">

</div>

<div class="container">

    <label><b>Username</b></label>

    <input type="text" placeholder="Enter Username" name="uname" required>

    <label><b>Password</b></label>

    <input type="password" placeholder="Enter Password" name="psw" required>

    <button type="submit">Login</button>

    <input type="checkbox" checked="checked"> Remember me

</div>

<div class="container" style="background-color:#f1f1f1">

    <span class="psw">Forgot <a href="#">password?</a></span>

    <span class="signup">New user <a href="signup">Sign Up?</a></span>

</div>

<div>

    <button type="button" class="cancelbtn">Cancel</button>

</div>

`

我的控制器是:

namespace App\Http\Controllers;

use Illuminate\Http\Request;

class HomeController extends Controller
{
    public $restful = true;

    public function showLogin()
    {
        // show the form
        return View::make('HomeController.login');
    }

    public function doLogin()
    {
        // process the form
    }
}

【问题讨论】:

    标签: php mysql laravel-5 namespaces laravel-artisan


    【解决方案1】:

    你应该添加:

    use View;
    

    行后:

    use Illuminate\Http\Request;
    

    没有它,您将尝试使用当前命名空间中的View,这是App\Http\Controllers

    【讨论】:

    • 不正确我现在收到此错误 * 在路径列表中查找给定视图。参数字符串 $name 参数数组 $paths 返回字符串 throws \InvalidArgumentException protected function findInPaths($name, $paths) {foreach ((array) $paths as $path) { foreach ($this->getPossibleViewFiles($name) as $file ) { if ($this->files->exists($viewPath = $path.'/'.$file)) { return $viewPath;} }} throw new InvalidArgumentException("View [$name] not found.") ; }
    • 我得到了更正,它应该是从返回语句中删除控制器名称,它应该只是视图名称。像 return View::make('login');
    猜你喜欢
    • 2020-02-02
    • 2016-06-02
    • 2016-05-15
    • 2017-07-12
    • 2019-04-14
    • 2015-12-18
    • 2017-11-29
    • 2017-08-10
    • 2020-04-13
    相关资源
    最近更新 更多