I think you can put it wherever you want. You only have to autoload it in you composer file.
You have to put this in the autoload section.
"files": ["path/to/yourfile.php"],
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
I'd like to add a file that just has functions available. Where is the best place to include this? start.php or global.php?
Autoload it in your composer.json.
"autoload": {
"classmap": [
"app/commands",
"app/controllers",
"app/models",
"app/database/migrations",
"app/database/seeds",
"app/tests/TestCase.php"
],
"files": [
"app/helpers.php"
]
}
Edit: Damn, ax3l beat me to it! haha. Basically add whatever filepath it is to your "files" array in composer.json.
Please or to participate in this conversation.