2

I'm working on CakePHP 3.4

I have a shell script to run as cron and send email to the user, email contains a link back to the website to specified controller.

To achieve this, I'm using Router::url() in the Shell to generate base url becuase Html->link is not working there

$fullBaseUrl = Router::url('/', true);
$scan_result_url = Router::url(['controller' => 'Notifications', 'action' => 'notificationRedirect', $notification->id], true);

But this is generating url with localhost as host like

http://localhost/notifications/notification-redirect/<id>

Same line in Controller when tested gives url to be

http://mywebsite.com/notifications/notification-redirect/<id>

How can I get full url in Shell. My website is hosted on server and using mywebsite.com to access it?

Anuj TBE
  • 9,198
  • 27
  • 136
  • 285
  • **http://stackoverflow.com/questions/38785795/full-urls-in-emails-in-cakephp-unittest** – ndm Apr 22 '17 at 16:19

1 Answers1

0

Cron won't pick the server url in your application. You'll need to set a constant in the config file and use that only. To do it the cake way, have a look at this Full base url example

Community
  • 1
  • 1
gaganshera
  • 2,629
  • 1
  • 14
  • 21