A Package for adding a Helpers.php file to your Laravel Application

Posted by Andy Huggins on August 25, 2017

Ever need to add a Helpers file for some global functions in your Laravel Application? You might know you can create a file and then use composer.json to autoload that file into your app. But if you are like me, you might forget the syntax, then you have to look that up when you want to create your helpers.php file.

If you use Laravel, then you are extremely familiar with adding a package from Packagist. So I created a package to quickly add a helpers.php file to your Laravel app.

It's ready for Laravel 5.5 coming out next week, and uses the "Auto-Discovery" feature coming in 5.5 that means that it really could not be simpler to add this package and continue working.

In 5.5 you just need to do `composer require ahuggins/helpers`, it will generate the service provider loader that makes "Auto-Discover" work.

In 5.4 and below, you will still have to update your `config/app.php` file and add the following `AHuggins\Helpers\Providers\HelpersServiceProvider::class,`

Then, you just need to publish the file with `php artisan vendor:publish --tag=helpers` and then you should be ready to go with a place to store global functions.