Laravel HelpersServiceProvider.php


Now let's create a service provider. Let's put it under app/Providers:


namespace App\Providers;

class HelpersServiceProvider extends ServiceProvider
    public function register()
        require_once __DIR__ . '/../Helpers/document.php';

The above service provider load the helpers file and registers your custom function automatically. Please make sure you register this HelpersServiceProvider in your config/app.php under providers:

'providers' => [
     // [..] other providers