Matanya
Matanya

Reputation: 6346

Getting "Class HTML not found" error in Laravel 4

Working on a new project in Laravel 4 (a.k.a Illuminate) I'm trying to create the link to the style sheet in my master.blade.php template like so:

    {{ HTML::style('css\style.css') }}

But this throws an error saying the class HTML wasn't found. Has it been removed or renamed in Laravel 4, or am I forgetting anything else?

Upvotes: 8

Views: 12491

Answers (7)

iicmaster
iicmaster

Reputation: 111

They just bring it back in Apr 02, 2013, But use Html instead HTML

eg. {{ Html::style('css\style.css') }} (now they change it again, this is not working anymore)

Refer: Add missing HTML::script and HTML::style

Update : Its "HTML" again!!! (Thanks @milad-rey)

for now please use this {{ HTML::style('css\style.css') }}

Refer: Updates for the rename of the HTML facade.

Upvotes: 11

quantme
quantme

Reputation: 3657

<?php /* outputs string: http://yoursite.com/pathToAsset */ ?>
{{ URL::asset('/css/style.css') }}

<?php /* outputs html tag: `<a href="http://yoursite.com/home">Home</a>` */ ?>
{{ Html::link('home', 'Home') }}

Check /vendor/laravel/frameworj/src/Illuminate//Html/HtmlBuilder.php methods. Don't know where the *ell is /vendor folder? You've been missing Composer.

composer.json

The best part (no more 'illumination/foundation', 'til now):

{
  ...
  "require": {
    ...
    "laravel/framework": "4.0.*"
  },
  ...
}

Proved 'til 2013-05-03 12:50

Upvotes: 0

scrfix
scrfix

Reputation: 1188

It has been removed. However there are a couple of things you can do Try out the: http://laravelbook.github.io/laravel4-powerpack/ The powerpack states that it will bring it back.

OR use the HTML such as mentioned in another post:

<link rel="stylesheet" type="text/css" href="{{ URL::to('pathto/styleheet.css') }}" />

For hyperlinks to named routes just in case other people are looking for them as well:

echo "<a href=\"" . URL::route('routeNameHere') . "\">Control Page</a>";
or $url = URL::route('routeNameHere');

see http://four.laravel.com/docs/routing

Upvotes: 0

EpokK
EpokK

Reputation: 38092

HTML and Form classes have been removed. You can install HTML port with composer here : https://github.com/meido/html

or you can use this (on Laravel 4 Beta 5) :

<link rel="stylesheet" type="text/css" href="{{ URL::to('to/my/style.css') }}" />

Upvotes: 4

Megamind
Megamind

Reputation: 249

use URL::asset('pathToAsset') ... i'm not quite sure, if this will be deprecated.

Upvotes: 4

daylerees
daylerees

Reputation: 1006

The generator type classes such as HTML:: and Form:: have been removed from L4 for best practice reasons. It would be better to render as tag using the path() method to link the attribute :

<link href="{{ path('to/my/style.css') }}" />

They may be added in later for backwards compatibility, we will see. Please remember that L4 is currently in an alpha state.

Thanks! Dayle Rees.

Upvotes: 17

William Cahill-Manley
William Cahill-Manley

Reputation: 2405

In Laravel 4 both the HTML and Form classes have been removed due to existing third party packages that can now be found via composer. You can search for one you like, or meido has ported the existing HTML and Form classes over. See their pages for install instructions.

Upvotes: 3

Related Questions