How to set subdirectory for laravel base url?

Usually laravel detects the base url automatically. However, this is not possible if the function is called using the command line in the console. So in path_to_laravel_folder / public / config / app.php there is a variable called url which, according to the official comment, should be the base url when calling laravel on the command line.

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

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

      

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

http://localhost/

      

Is this a bug, or does the subdirectory have to be installed somewhere else?


PS

As suggested in the comment session, I am adding some details about what function I was calling for the base url.

In fact, I am writing a daily job to send email to remind the user to do something on my site. It will first read from the database the user wants a reminder for and sends an email if that user is in our database. The function that needs the base url is in the email view file, 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 -->

      

$ user_id is set in the command file. The link will be redirected to the login page as the user has not yet registered.

+3


source to share





All Articles