Search code examples
htmllaravelckeditorlaravel-facade

How to using echo HTML::script in laravel 5.0 in Controller


I need to use

echo HTML::script('js/ckeditor/ckeditor.js');

in my controller and function, but error not found HTML

I am using larvel 5.0. tnx


Solution

  • HTML and FORM are removed from Laravel 5+ to use them you have to include them in composer.json. And add an Alias and Service Provider in config\app.php You can find them here

    And as from laravel 5 {{}} is same as {{e('sting')}} //htmlentities To output html you need to use {!! HTML::() !!} without htmlentities

    And if you need to use echo Simply wrap it to <?php ?> tags <?php echo HTML::() ?>

    And if you use it Controller you need to use like \Html::() or before Controller class add use HTML;

    HTML or Html depends on you Alias array in config\app.php

    composer.json

    "illuminate/html": "^5.0",
    

    Config/app.php Service Provider

    'Illuminate\Html\HtmlServiceProvider',
    

    Config/app.php aliases

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

    Controller

    <?php namespace App\Http\Controllers;
    use HTML;
    class SomeController extends Controller{
        public function foo(){
            echo HTML::();
        }
    }