How to set sub-directory for base URL of laravel?

被刻印的时光 ゝ 提交于 2019-12-23 11:39:08

问题


Normally laravel will detect the base url automatically. However, this is not possible when the function is called by command line in console. Therefore, under path_to_laravel_folder/public/config/app.php, there is a variable named url, which according to the official comment, should be the base url when laravel is called in command line.

Currently I have a daily task to be run on laravel and therefore is called by command line. In the app.php, I have set the url variable to be:

'url' => 'http://localhost/laravel/public/',

However, when I check the output of my daily job, the base url is always

http://localhost/

Is this a bug or the sub-directory should be set else where?


P.S.

As suggested in the comment session, I am adding some details on what function I called for base url.

Actually, I am writing a daily job to send email to remind the user to do something on my site. It will first read from database on which user wants a reminder and sends a email if this user is found in our database. The function that need the base url is in the view file of the email, namely path_to_laravel/public/view/email/reminder.blade.php The code looks like this:

<!-- some other email content-->
... <a href="{{ url('/controllerName/method/'.$user_id) }}"> click here to go to the site </a> ....
<!-- some other email content -->

The $user_id is set in command file. The link will redirect to login page is user is not login yet.

来源:https://stackoverflow.com/questions/27103555/how-to-set-sub-directory-for-base-url-of-laravel

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!