/dev/Blog/Post: Package: Laravel AutoHelpers

Package: Laravel AutoHelpers

Package: Laravel AutoHelpers

I made it. I released a new package.

Basically because I wanted to scratch my own itch.
On almost every single project I am working on needs helpers.

But configuring the corresponding files is always keeping me away from using dedicated helper-files.

So I came up with the idea for a new package that allows you to load the helper-files automatically.

Installation
You can install the package via composer:
composer require fwartner/laravel-auto-helpers

Create the folders:
php artisan autohelper:install

Usage
To automatically load your helpers you'll need to update your AppServiceProvider.php within the boot() method like this:
/**
* Bootstrap any application services.
*
* @return void
*/
public function boot()
{
    LaravelAutoHelpers::boot();
}

Now create a helper in the app/Helpers directory and you're all set:

<?php

if (! function_exists('appName')) {
    /**
     * Helper to grab the application name.
     *
     * @return mixed
     */
    function appName()
    {
        return config('app.name');
    }
}

The source is available on GitHub.

Don't want to miss anything?

Sign up for my newsletter and get the latest stuff that I publish.

I don't sell your email to anyone. I promise!