Optionally we recommend to create a html() helper method. This way you can easily access the Html instance and get code completion in your favourite IDE.
Start by creating the file app/helpers.php and add the following method:
<?php
useSpatie\Html\Html;
functionhtml(): Html
{
returnapp(Html::class);
}
Next we'll need to tell composer to automatically load this file. We can do this by modifying composer.json. Look for the autoload section and add app/helpers.php to the files array:
{"autoload": {"files": ["app/helpers.php"]}}
Finally dump the current autoloader with the following command:
composer dump-autoload
We don't ship the helper method in the package for two reasons:
Some people prefer not to pollute the global namespace with helpers
By defining your own helper method, you could change the return type to your own Html class which extends this packages' base class, so you can add your own shortcut methods