How to add a helpers file to a Laravel Project

A step-by-step guide to add your own helpers file to a Laravel project

Wyatt
Wyatt
Jan 1 · 1 min read

✅ Open project in editor

✅ Create helpers.php file somewhere in App directory

App\
| helpers.php

✅ Open composer.json

✅ Add the files array to the “autoload” section

\\composer.json"autoload": {   "psr-4": {      "App\\": "app/"   },   "classmap": [      "database/seeds",      "database/factories"   ],   "files": [      "app/helpers.php"   ]},

✅ Dump the composer autoloader

composer dump-autoload

✅ Done, now write your custom helper functions!


Wyatt

Written by

Wyatt

NMSU Alum - Learner, Maker, Teacher