Laravel: Get base url

后端 未结 17 1937
梦谈多话
梦谈多话 2020-12-07 10:09

Simple question, but the answer seems quite hard to come by. In Codeigniter, I could load the url helper and then simply do

echo base_url();
<
17条回答
  •  春和景丽
    2020-12-07 10:29

    By the way, if your route has a name like:

    Route::match(['get', 'post'], 'specialWay/edit', 'SpecialwayController@edit')->name('admin.spway.edit');
    

    You can use the route() function like this:

    Other useful functions:

    $uri = $request->path();
    $url = $request->url();
    $url = $request->fullUrl();
    asset()
    app_path();
    // ...
    

    https://github.com/laravel/framework/blob/5.4/src/Illuminate/Foundation/helpers.php

提交回复
热议问题