1

Before any of you moderators go marking this as a duplicate, I urge you to consider the fact that I have scoured SO and google for Laravel 6 specific topics regarding my problem and have only found ONE thing specific to 6. If anyone can help resolve this, I'm certain this will help tons of Laravel developers. So, please be conscientious of this circumstance not only for my sake, but the community?

When I attempt to load my page, which is making use of the HTML class in question using;

{{ HTML::style('assets/css/bootstrap.min.css') }}

for my css files and the respective HTML::script call for my js files and all I keep getting reported back is;

Class 'HTML' not found (View: /Users/pshore/PhpstormProjects/upeeps/resources/views/subpages/header.blade.php)

First of all, I have already visited this SO post, and;

This did not resolve my issue

So, I am now providing my composer.json contents, my config/app.php contents in the hopes that someone will see a mistake in my configuration that is causing this.

I have tried everything from downgrading my laravel to 5.8.35 to tons of things found here and on Google for Laravel 5, but hardly anything exists for Laravel 6 regarding this issue. So, I've hit a dead end and can no longer figure out a good next step other than to post here.

composer.json

{
  "name": "laravel/laravel",
  "type": "project",
  "description": "The Laravel Framework.",
  "keywords": [
    "framework",
    "laravel"
  ],
  "license": "MIT",
  "require": {
    "php": "^7.2",
    "fideloper/proxy": "^4.0",
    "laravel/framework": "^6.0",
    "laravel/tinker": "^1.0",
    "laravelcollective/html": "^6.0"
  },
  "require-dev": {
    "facade/ignition": "^1.4",
    "fzaninotto/faker": "^1.4",
    "mockery/mockery": "^1.0",
    "nunomaduro/collision": "^3.0",
    "phpunit/phpunit": "^8.0"
  },
  "config": {
    "optimize-autoloader": true,
    "preferred-install": "dist",
    "sort-packages": true
  },
  "extra": {
    "laravel": {
      "dont-discover": []
    }
  },
  "autoload": {
    "psr-4": {
    "App\\": "app/"
  },
    "classmap": [
      "database/seeds",
      "database/factories"
    ]
  },
  "autoload-dev": {
    "psr-4": {
      "Tests\\": "tests/"
    }
  },
  "minimum-stability": "dev",
  "prefer-stable": true,
  "scripts": {
    "post-autoload-dump": [
      "Illuminate\\Foundation\\ComposerScripts::postAutoloadDump",
      "@php artisan package:discover --ansi"
    ],
    "post-root-package-install": [
      "@php -r \"file_exists('.env') || copy('.env.example', '.env');\""
    ],
    "post-create-project-cmd": [
      "@php artisan key:generate --ansi"
    ]
  }
}

config/app.php

'providers' => [

    /*
     * Laravel Framework Service Providers...
     */
    Illuminate\Auth\AuthServiceProvider::class,
    Illuminate\Broadcasting\BroadcastServiceProvider::class,
    Illuminate\Bus\BusServiceProvider::class,
    Illuminate\Cache\CacheServiceProvider::class,
    Illuminate\Foundation\Providers\ConsoleSupportServiceProvider::class,
    Illuminate\Cookie\CookieServiceProvider::class,
    Illuminate\Database\DatabaseServiceProvider::class,
    Illuminate\Encryption\EncryptionServiceProvider::class,
    Illuminate\Filesystem\FilesystemServiceProvider::class,
    Illuminate\Foundation\Providers\FoundationServiceProvider::class,
    Illuminate\Hashing\HashServiceProvider::class,
    Illuminate\Mail\MailServiceProvider::class,
    Illuminate\Notifications\NotificationServiceProvider::class,
    Illuminate\Pagination\PaginationServiceProvider::class,
    Illuminate\Pipeline\PipelineServiceProvider::class,
    Illuminate\Queue\QueueServiceProvider::class,
    Illuminate\Redis\RedisServiceProvider::class,
    Illuminate\Auth\Passwords\PasswordResetServiceProvider::class,
    Illuminate\Session\SessionServiceProvider::class,
    Illuminate\Translation\TranslationServiceProvider::class,
    Illuminate\Validation\ValidationServiceProvider::class,
    Illuminate\View\ViewServiceProvider::class,

    Collective\Html\HtmlServiceProvider::class,

    /*
     * Package Service Providers...
     */

    /*
     * Application Service Providers...
     */
    App\Providers\AppServiceProvider::class,
    App\Providers\AuthServiceProvider::class,
    // App\Providers\BroadcastServiceProvider::class,
    App\Providers\EventServiceProvider::class,
    App\Providers\RouteServiceProvider::class,

],

'aliases' => [

    'App' => Illuminate\Support\Facades\App::class,
    'Arr' => Illuminate\Support\Arr::class,
    'Artisan' => Illuminate\Support\Facades\Artisan::class,
    'Auth' => Illuminate\Support\Facades\Auth::class,
    'Blade' => Illuminate\Support\Facades\Blade::class,
    'Broadcast' => Illuminate\Support\Facades\Broadcast::class,
    'Bus' => Illuminate\Support\Facades\Bus::class,
    'Cache' => Illuminate\Support\Facades\Cache::class,
    'Config' => Illuminate\Support\Facades\Config::class,
    'Cookie' => Illuminate\Support\Facades\Cookie::class,
    'Crypt' => Illuminate\Support\Facades\Crypt::class,
    'DB' => Illuminate\Support\Facades\DB::class,
    'Eloquent' => Illuminate\Database\Eloquent\Model::class,
    'Event' => Illuminate\Support\Facades\Event::class,
    'File' => Illuminate\Support\Facades\File::class,
    'Gate' => Illuminate\Support\Facades\Gate::class,
    'Hash' => Illuminate\Support\Facades\Hash::class,
    'Lang' => Illuminate\Support\Facades\Lang::class,
    'Log' => Illuminate\Support\Facades\Log::class,
    'Mail' => Illuminate\Support\Facades\Mail::class,
    'Notification' => Illuminate\Support\Facades\Notification::class,
    'Password' => Illuminate\Support\Facades\Password::class,
    'Queue' => Illuminate\Support\Facades\Queue::class,
    'Redirect' => Illuminate\Support\Facades\Redirect::class,
    'Redis' => Illuminate\Support\Facades\Redis::class,
    'Request' => Illuminate\Support\Facades\Request::class,
    'Response' => Illuminate\Support\Facades\Response::class,
    'Route' => Illuminate\Support\Facades\Route::class,
    'Schema' => Illuminate\Support\Facades\Schema::class,
    'Session' => Illuminate\Support\Facades\Session::class,
    'Storage' => Illuminate\Support\Facades\Storage::class,
    'Str' => Illuminate\Support\Str::class,
    'URL' => Illuminate\Support\Facades\URL::class,
    'Validator' => Illuminate\Support\Facades\Validator::class,
    'View' => Illuminate\Support\Facades\View::class,

    'Form' => Collective\Html\FormFacade::class,
    'Html' => Collective\Html\HtmlFacade::class
],
Skittles
  • 2,866
  • 9
  • 31
  • 37
  • You've made sure to run `composer install` after updating `composer.json`? (I assume so, but have to check). And it may or may not help, but running `composer dump-autoload` after. Lastly, does it work with `\HTM::style()`? Good on you for showing you've done research too :) – Tim Lewis Oct 04 '19 at 20:12
  • Make sure the config isn't cached at the moment, `php artisan config:clear`, just in case. Also `Html` or `HTML`, its nice to pretend case matters to keep consistency. – lagbox Oct 04 '19 at 20:22
  • I've done that and config:clear and even view:clear & view:cache, along with clear-compiled. All of which isn't working. @TimLewis - Yes, I've done that also. Thank you for that suggestion, btw. – Skittles Oct 04 '19 at 20:22
  • @TimLewis _ No, the backslash is also not working. I really was hopeful about that one as I have not tried that yet. – Skittles Oct 04 '19 at 20:25
  • @lagbox - You are seriously a savior! It absolutely was the case of the HTML. Please post an answer so I can accept it and upvote it?! This is going to be so valuable to other folks! Thanks you so much! – Skittles Oct 04 '19 at 20:27
  • Rats; was hoping that would have worked. Out of curiosity, was `HTML` removed in `v6.0`? I'm looking through the documentation https://laravelcollective.com/docs/6.0/html and I don't see any instances of `HTML::`. I also don't see any notes about including the `ServiceProvider` and `Alias`, but that's generally standard practice for Laravel packages. Do any of the method from https://laravelcollective.com/docs/6.0/html#generating-urls work? Like `link_to_asset()` for example? **Edit** Just saw the comment about case-sensitivity; sounds like that's it :) – Tim Lewis Oct 04 '19 at 20:30
  • @TimLewis - I'm inclined to agree that it's missing by intention, but if so, then the Laravel peeps should really provide much better indications there of in their docs or at the very lest, a changelog entry. – Skittles Oct 04 '19 at 20:34
  • Haha yeah, agreed. I rarely used the `Form` syntax even when it was included in Laravel by default, preferred the control of writing out the HTML. But regardless; glad you got it working. – Tim Lewis Oct 04 '19 at 20:36

1 Answers1

1

You are probably going to want to use the exact aliased class name for this (case sensitive), Html based on your config:

{{ HTML::style('assets/css/bootstrap.min.css') }}

// would become

{{ Html::style('assets/css/bootstrap.min.css') }}

The package itself uses the auto discovery feature so you don't have to include the service provider or the aliases yourself. It will alias the HtmlBuilder to Html and FormBuilder to Form for you.

lagbox
  • 48,571
  • 8
  • 72
  • 83
  • How can I tell in the future about the auto-discovery side of things? Is this something that is just assumed as the norm from some release forward? Again...thank you sooo much! – Skittles Oct 04 '19 at 20:36
  • Laravel sets some comands to run after composer does an autoload dump so you should see something like `@php artisan package:discover --ansi` on the command line and it will then list the packages it was able to discover. I would think most packages should mention that they use this functionality. If not, you can check the `composer.json` file of the package and look for a specific section named `extra` then `laravel` under that. Also this stuff is listed in `bootstrap/cache/packages.php` after that command has ran. – lagbox Oct 04 '19 at 20:53
  • This is great knowledge to add to my laravel experiences. I totally appreciate all you help. – Skittles Oct 06 '19 at 13:57