Helper Functions: A Love Note (and a package)

Dear Helper Functions,

You are an escape. In a world of rigid object-orientation, you offer freedom and fluidity to my workflow. Composition? Inheritance? Namespacing? You don't concern me with such things, you keep it simple. Do you know how refreshing that is? To not have to ponder the meaning of life just to add some simple functionality?

You are personal. You really know my application. You might not fit very well in other applications, and you're ok with that.

You are fun. You don't take yourself too seriously. Not like those other language structures, with their patterns and best practices. Dogma eludes you, you don't get caught up in the twitter drama, you don't have time for that noise.

You are simple. One way in, and one way out. No need to scroll around or hop between pages. I can read and understand you in one go. No need to bust out the map and compass.

You are available. You don't need to be imported, you're already there, just waiting to be called.

You are many things to many people, but most of all, you are helpful.

Your friend,
- Caleb


But seriously, I made a tiny, silly package because I add an app/helpers.php file to every Laravel project and I can never remember how to autoload them in my composer.json file. Matt Stauffer and I brainstormed this idea a while back, but never got around to building it.

So rather than spending 1 minute looking at a different project or googling it, I can now spend one minute trying to remember what this package is called. Or if I'm feeling ambitious, add it to my Lambo config.

Installation

composer require calebporzio/laravel-helpers-file

Usage

Well.. that's it. Everything in app/helpers.php is now available globally in your app.

Too lazy to add a app/helpers.php file? No worries:

php artisan calebporzio:helpers

(Bonus points for creating a resources/views/_helpers.blade.php file for some more javascript helper fun!)


So there you go, rather than spending 1 minute looking it up, I spent an hour making this package and blog post. I hope at least 60 of you use this someday.

👋