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.

  1. Create a folder in app\Http folder. Let’s assume you created Helpers
  2. You can place any number of php files in this directory.
  3. Then open composer.json found in your root directory and find
"autoload-dev": {
    "psr-4": {
      "Tests\\": "tests/"
    }
  }
  1. Then replace it so it looks like this
"autoload-dev": {
    "psr-4": {
      "Tests\\": "tests/"
    },
    "files": [
      "app/Helpers/filename.php"
    ]
  }
  1. Finally, run composer dump-autoload and you are good to go