Laravel add http to urls

后端 未结 1 968
独厮守ぢ
独厮守ぢ 2021-01-27 05:21

Is there a helper in Laravel 5.0 that automatically adds http to a url without it? This is similar to codeigniter\'s prep_url that could be found here.

1条回答
  •  耶瑟儿~
    2021-01-27 05:31

    No but you can add it yourself. In your composer.json file add a files key under autoload and point it your helper file e.g.

    "autoload": {
        "files": [
            "app/helpers.php"
        ]
    }
    

    Then create app/helpers.php with the code (lifted from https://github.com/bcit-ci/CodeIgniter/blob/master/system/helpers/url_helper.php):

    Now you have prep_url globally accessible! Don't forget to run a composer dump-autoload too.

    0 讨论(0)
提交回复
热议问题