Best Practices for Custom Helpers in Laravel 5

后端 未结 20 2276
暖寄归人
暖寄归人 2020-11-22 06:40

I would like to create helper functions to avoid repeating code between views in Laravel 5:

view.blade.php

Foo Formated text: {{ fo

20条回答
  •  温柔的废话
    2020-11-22 07:32

    This is what is suggested by JeffreyWay in this Laracasts Discussion.

    1. Within your app/Http directory, create a helpers.php file and add your functions.
    2. Within composer.json, in the autoload block, add "files": ["app/Http/helpers.php"].
    3. Run composer dump-autoload.

提交回复
热议问题