Best Practices for Laravel 4 Helpers and Basic Functions?

后端 未结 4 1676
有刺的猬
有刺的猬 2020-11-30 16:20

I\'m trying to understand the best place to put a global function in Laravel 4. For example, date formatting. I don\'t think making a facade is worth it as facades are too m

4条回答
  •  鱼传尺愫
    2020-11-30 17:02

    You can also use View::share() together with closures to achieve this - I just posted about this: http://www.develophp.org/2014/07/laravel-4-blade-helper-functions/

    Added benefit: You don't need to create an extra class and also keep the global namespace clean.

提交回复
热议问题