php - Laravel - Artisan gives wrong base url -
my app/config/app.php has
'url' => 'http://dev.domain.com/something/somethingelse' then have function can called application , artisan command. url::route('myroute') returns different results. when called application returns http://dev.domain.com/something/somethingelse/myroute, in artisan command http://dev.domain.com/myroute.
url::to has same behaviour.
note: not have other app.php file defined other environments overwrite global one.
any ideas why happens ? thanks!
a laravel-generated url consists of number of parts:
- scheme:
http://,https://, etc. - host:
dev.domain.com,localhost, etc. - base:
something/somethingelse(the subdirectory on web server) - tail:
myroute, (the laravel route parameters)
these parts concatenated form url.
ultimately, laravel generates url using $_server request variables. function preparebaseurl() in symfony\component\httpfoundation\request used determine base part of url.
when make request through web browser, request goes ~/public/index.php , necessary $_server variables populated correct information laravel populate base part of url.
however, when make request using artisan on command line, request goes ~/artisan script. means $_server variables not populated in same way , laravel not able determine base part of url; instead, returns empty string ''.
from can find, doesn't there appetite laravel team enable application function out-of-the-box in subdirectory, e.g. bugfix: domain routing subfolder.
i ended working around in way described @medowlock scripts called command line, e.g.:
config::get('app.url') . url::route('route.name', ['parameter'=>'value'], false)
this concatenates application url set in app/config/app.php , relative url route.
Comments
Post a Comment