Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
186 views
in Technique[技术] by (71.8m points)

php - Undefined namespace html (adding a css file to blade) laravel

I'm having trouble with importing a css style sheet located in public/css in a blade file located in resources/views/includes.

The code I used in the blade file is

{{ HTML::style('css/layout.css') }}

which didn't work. I also tried

{{ HTML::style('css/layout.css', array('media' => 'print')) }}

The error I get is Class 'HTML' not found

I followed the steps in this question, so

  1. I added "laravelcollective/html": "5.4.16" in composer.json
  2. run composer update
  3. added in config/app.php

    'providers' => [
    CollectiveHtmlHtmlServiceProvider::class,
    ]
    
  4. and

    'aliases' => [
    
            'Form' => CollectiveHtmlFormFacade::class,
            'HTML' => CollectiveHtmlHtmlFacade::class,
    ]
    

Now the error I get is

Class 'CollectiveHtmlHtmlServiceProvider' not found

And I don't understand why, as I added it to app.php. Indeed, when I go to app.php and the line where I added Collective.., the "Html" is colored in red and when I hover over it it says

Undefined namespace Html

What should I do about it? All this laravel thing is getting confusing to me.

Apart from the fact that I don't know what to do with,

{{HTML::linkAction('MemberController@show', 'view', array($value->id))}}

i found nothing online regarding the arguments of "linkAction"

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

1:Remove "laravelcollective/html": "5.4.16" in composer.json and clean other config for this package in config/app.php.

2:Run composer update

3:Run composer require laravelcollective/html

4:Add 'CollectiveHtmlHtmlServiceProvider::class', in config/app.php (providers)

5:Add 'Form' => CollectiveHtmlFormFacade::class, and 'Html' => CollectiveHtmlHtmlFacade::class, in config/app.php (aliases)

6:In controller try use Html; and use Form;

If you get any other error please share composer.json and config/app.php.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...