There are some cases when you need to add your own custom functions in Laravel. I often have my own custom helpers for speeding up development. You can easily add your own files by following this quick guide.
- Create a folder in
app\Http
folder. Let’s assume you createdHelpers
- You can place any number of
php
files in this directory. - Then open
composer.json
found in your root directory and find
"autoload-dev": {
"psr-4": {
"Tests\\": "tests/"
}
}
- Then replace it so it looks like this
"autoload-dev": {
"psr-4": {
"Tests\\": "tests/"
},
"files": [
"app/Helpers/filename.php"
]
}
- Finally, run
composer dump-autoload
and you are good to go