In bootstrap/start.php
I think this is a bad idea, this file is used to load autoload
and start the Laravel classes itself.
No app/start/global.php
would work, but you'd lose some of the organization. (Remember that app/start/global.php
no longer exists in Laravel 5).
I would create a separate file inside my folder app
, something like macros.php
and load it by composer.json:
"autoload": {
"classmap": [
"app/commands",
"app/controllers",
"app/models",
"app/database/migrations",
"app/database/seeds",
"app/tests/TestCase.php"
],
"files": [
"app/macros.php"
]
},
Another way would be to define a Service Provider to create all these macros. The own documentation places an example involving the macro
method in the boot
method of a Service Provider in>:
Use Illuminate \ Contracts \ Routing \ ResponseFactory;
public function boot(ResponseFactory $factory)
{
$factory->macro('caps', function ($value) {
//
});
}
Anyway, there is no right place for this. One of the cool points of Laravel is that it allows a flexible architecture for your application. So choose what you think is best for your project.