在Laravel 5中加载视图时出错 [英] Error loading view in Laravel 5

查看:66
本文介绍了在Laravel 5中加载视图时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试加载我的创建视图,

I'm trying to load my create view,

public function create()
    {
        //
        return View('my.create');
    }

但是我遇到这个错误,

85b8c1799c6cd6f2475229a36bc0e59a39b0e295.php第23行中的FatalErrorException:未找到类'HTML'

FatalErrorException in 85b8c1799c6cd6f2475229a36bc0e59a39b0e295.php line 23: Class 'HTML' not found

create.blade.php

create.blade.php

<!DOCTYPE html>
<html>
<head>
    <title>Look! I'm CRUDding</title>
    <link rel="stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css">
</head>
<body>
<div class="container">

<nav class="navbar navbar-inverse">
    <div class="navbar-header">
        <a class="navbar-brand" href="{{ URL::to('nerds') }}">Nerd Alert</a>
    </div>
    <ul class="nav navbar-nav">
        <li><a href="{{ URL::to('nerds') }}">View All Nerds</a></li>
        <li><a href="{{ URL::to('nerds/create') }}">Create a Nerd</a>
    </ul>
</nav>

<h1>Create a Nerd</h1>

<!-- if there are creation errors, they will show here -->
{{ HTML::ul($errors->all()) }}

{{ Form::open(array('url' => 'nerds')) }}

    <div class="form-group">
        {{ Form::label('name', 'Name') }}
        {{ Form::text('name', Input::old('name'), array('class' => 'form-control')) }}
    </div>

    <div class="form-group">
        {{ Form::label('email', 'Email') }}
        {{ Form::email('email', Input::old('email'), array('class' => 'form-control')) }}
    </div>

    <div class="form-group">
        {{ Form::label('nerd_level', 'Nerd Level') }}
        {{ Form::select('nerd_level', array('0' => 'Select a Level', '1' => 'Sees Sunlight', '2' => 'Foosball Fanatic', '3' => 'Basement Dweller'), Input::old('nerd_level'), array('class' => 'form-control')) }}
    </div>

    {{ Form::submit('Create the Nerd!', array('class' => 'btn btn-primary')) }}

{{ Form::close() }}

</div>
</body>
</html>

以上视图位于其名为my的自己的目录中.我在WAMP服务器中使用Laravel 5.2.

the above view is located in its iwn directory called my. I'm using Laravel 5.2 in WAMP server.

推荐答案

我认为您在视图中使用的是经典"外观(已经存在很长时间了)HTML外墙.

I guess you're using the "classic" (has been there for long) HTML façade in your view.

好吧,在Laravel> 5.1(IIRC)中不再存在.如果您想要相同的功能,可以参考LaravelCollective软件包,您可以在这里找到它:

Well, it's no longer there in Laravel > 5.1 (IIRC). If you want the same functionalities, you can refer to the LaravelCollective package you can find here:

https://laravelcollective.com/docs/5.2/html

您可以像其他任何软件包一样,通过Composer轻松安装它.请注意,Form类也是如此.

You can install it easily with Composer, as any other package. The same applies for the Form class, mind it.

这篇关于在Laravel 5中加载视图时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆