Alana Storm
Alana Storm

Reputation: 166106

Distinction Between Foundation Helpers and Support Helpers

In Laravel 5, there are now two helpers.php files

"files": [
    "src/Illuminate/Foundation/helpers.php",
    "src/Illuminate/Support/helpers.php"
],

Is there any logical distinction between what's a foundation helper and what's a support helper? i.e. if I was a Laravel core developer, how would I decide which file my new helper function belonged in?

Upvotes: 1

Views: 222

Answers (1)

Joel Hinz
Joel Hinz

Reputation: 25404

The foundation helpers file is for functionality directly related to the framework, like shortcuts for popular methods such as get() instead of $router->get() or Route::get(). You'll notice that of 35 functions (currently), almost all have variations of return app(...) or other similar IoC container calls.

The support helpers file is for small functions that improve php but are for the most part not really related to Laravel per se. That includes all of the str_ and array_ functions, for instance - functions that could just as well have been a part of the php standard library, and do not rely on the framework to work.

Upvotes: 3

Related Questions