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\Httpfolder. Let’s assume you createdHelpers - You can place any number of
phpfiles in this directory. - Then open
composer.jsonfound 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-autoloadand you are good to go