Unisys12's Blog

My adventures, trials & tribulations of learning web development as a hobby! I mean... who does that?


Getting Illuminate\HTML Back into Laravel v5 Beta

Phillip Jackson - 2014-09-25 00:43:58
How to install and integrate Laravels HTML helpers back into Laravel v5 Beta

Seems My Blade is Dull

If you have played with Laravel v5 Beta or plan on taking the plunge in the near future, one thing you might have noticed or will notice, is that some of Blade's helpers are missing. This was a choice author, Taylor Otwell, made and I can sorta understand why. He has made it pretty clear on the Laravel IO Podcast, that he really could care less about the package 'Illuminate/Html'. And if you listen to his point of view, it makes perfect sense. But, as with most Laravel users, I love Blade! And I really have missed it while playing with the beta release of Laravel 5. Plus, let's get over ourselves here! It's not like he deleted it or is not supporting it any longer! You can still add it back to your next v5 project in just a few minutes time.

Download Illumninate\HTML

HTML and the FormBuilder classes live within a package called Illuminate\Html. I would suggest getting the package through Packagist, just as you normally would. So let's update our composer.json file with the package information:

"require": {
    "laravel/framework": "~5.0",
    "illuminate/html": "~5.0"
},

Next, we just need to run our trusty composer update command to bring everything into our project. Or if your knee deep in a test project and do not want to run the risk of your app being blown away from code changes (it can happen and should be planned for. Remember, this is in beta and Taylor is actively making changes), run the following, from your terminal or command-line thingy of choice, instead:

composer require illuminate/html

Updating Our ServiceProvider and Alias

Finally, we only need to update the service provider for the new package and add the alias for our Form Facade within `app/config.php.

Within our providers array, add the line 'Illuminate\Html\HtmlServiceProvider', to the end of the array. Like so:

'providers' => [

        /*
         * Application Service Providers...
         */
        'App\Providers\AppServiceProvider',
        'App\Providers\ArtisanServiceProvider',
        'App\Providers\ErrorServiceProvider',
        'App\Providers\FilterServiceProvider',
        'App\Providers\LogServiceProvider',
        'App\Providers\RouteServiceProvider',

        /*
         * Laravel Framework Service Providers...
         */
        'Illuminate\Foundation\Providers\ArtisanServiceProvider',
        'Illuminate\Auth\AuthServiceProvider',
        'Illuminate\Cache\CacheServiceProvider',
        'Illuminate\Foundation\Providers\ConsoleSupportServiceProvider',
        'Illuminate\Cookie\CookieServiceProvider',
        'Illuminate\Database\DatabaseServiceProvider',
        'Illuminate\Encryption\EncryptionServiceProvider',
        'Illuminate\Filesystem\FilesystemServiceProvider',
        'Illuminate\Foundation\Providers\FoundationServiceProvider',
        'Illuminate\Hashing\HashServiceProvider',
        'Illuminate\Log\LogServiceProvider',
        'Illuminate\Mail\MailServiceProvider',
        'Illuminate\Pagination\PaginationServiceProvider',
        'Illuminate\Queue\QueueServiceProvider',
        'Illuminate\Redis\RedisServiceProvider',
        'Illuminate\Auth\Reminders\ReminderServiceProvider',
        'Illuminate\Session\SessionServiceProvider',
        'Illuminate\Translation\TranslationServiceProvider',
        'Illuminate\Validation\ValidationServiceProvider',
        'Illuminate\View\ViewServiceProvider',
        'Illuminate\Html\HtmlServiceProvider',

    ],

Finally, add the line 'Form' => 'Illuminate\Html\FormFacade', to the end of the aliases array, like so:

'aliases' => [

        'App'       => 'Illuminate\Support\Facades\App',
        'Artisan'   => 'Illuminate\Support\Facades\Artisan',
        'Auth'      => 'Illuminate\Support\Facades\Auth',
        'Blade'     => 'Illuminate\Support\Facades\Blade',
        'Cache'     => 'Illuminate\Support\Facades\Cache',
        'Config'    => 'Illuminate\Support\Facades\Config',
        'Cookie'    => 'Illuminate\Support\Facades\Cookie',
        'Crypt'     => 'Illuminate\Support\Facades\Crypt',
        'DB'        => 'Illuminate\Support\Facades\DB',
        'Event'     => 'Illuminate\Support\Facades\Event',
        'File'      => 'Illuminate\Support\Facades\File',
        'Hash'      => 'Illuminate\Support\Facades\Hash',
        'Input'     => 'Illuminate\Support\Facades\Input',
        'Lang'      => 'Illuminate\Support\Facades\Lang',
        'Log'       => 'Illuminate\Support\Facades\Log',
        'Mail'      => 'Illuminate\Support\Facades\Mail',
        'Paginator' => 'Illuminate\Support\Facades\Paginator',
        'Password'  => 'Illuminate\Support\Facades\Password',
        'Queue'     => 'Illuminate\Support\Facades\Queue',
        'Redirect'  => 'Illuminate\Support\Facades\Redirect',
        'Redis'     => 'Illuminate\Support\Facades\Redis',
        'Request'   => 'Illuminate\Support\Facades\Request',
        'Response'  => 'Illuminate\Support\Facades\Response',
        'Route'     => 'Illuminate\Support\Facades\Route',
        'Schema'    => 'Illuminate\Support\Facades\Schema',
        'Session'   => 'Illuminate\Support\Facades\Session',
        'URL'       => 'Illuminate\Support\Facades\URL',
        'Validator' => 'Illuminate\Support\Facades\Validator',
        'View'      => 'Illuminate\Support\Facades\View',
        'Form'        => 'Illuminate\Html\FormFacade',
    ],

That's it! Now, go code something already!!

LARAVEL, LARAVEL V5 BETA, BLADE, TEMPLATING
comments powered by Disqus