AL-zami
AL-zami

Reputation: 9066

Class html not found in laravel

I am trying to upload an image from my 'public/uploads/' folder.But whenever i run the page i get the following error.I am using 5.2

Class HTML not found

How i can remove this error?

@extends('main')

@section('content')

<h1>This is show.blade.php</h1>

    @if(isset($info))
    <div class='col-md-2 col-md-offset-2'>
        {{HTML::image('uploads/zami.jpg')}}
    </div>
    <div class='col-md-12'>
           <span>user id :</span><span>{{$info['info']['id']}}</span></br>
           <span>username :</span><span>{{$info['info']['username']}}</span></br>
    </div>
   @endif
@endsection

Upvotes: 2

Views: 3380

Answers (3)

Sanjay Chaudhari
Sanjay Chaudhari

Reputation: 420

Add this in composer.json require section

"illuminate/html": "5.*"

and run composer update

Open your config/app.php

add under 'providers' array add this

Illuminate\Html\HtmlServiceProvider::class,

add under 'aliases' array add this

'Form'      => Illuminate\Html\FormFacade::class,
'Html'      => Illuminate\Html\HtmlFacade::class,

and under your blade templates, use like this

{!! Html::image('uploads/zami.jpg') !!}

Hope it will help you.

Upvotes: 2

Alexey Mezenin
Alexey Mezenin

Reputation: 163748

If you have Laravel Collective installed, try to use:

{!! Html::image !!}

Instead of:

{{ Html::image }}

Upvotes: 1

Mihai Matei
Mihai Matei

Reputation: 24276

By default in Laravel 5.0, Html and Form are not embedded anymore.

Add the following line "illuminate/html": "5.*" in the require section of composer.json file and run composer update

Register the service provider in config/app.php by adding the following value into the providers array: Illuminate\Html\HtmlServiceProvider

Register facades by adding these two lines in the aliases array:

'Form'=> 'Illuminate\Html\FormFacade',
'HTML'=> 'Illuminate\Html\HtmlFacade'

Upvotes: 1

Related Questions