Dear,
I created some console actions, and like to send a e-mail in there with some URL’s in it. This URL’s should be created by UrlManager. But it isn’t rewriting at all.
I have the following /config/console.php config file;
return [
'id' => 'command',
'basePath' => dirname(__DIR__),
'bootstrap' => ['log', 'gii'],
'controllerNamespace' => 'app\commands',
'modules' => [
'gii' => 'yii\gii\Module',
],
'components' => [
'urlManager' => [
'baseUrl' => 'https://crm.myapp.nl/',
'scriptUrl' => '',
'rules' => [
'online-betalen/<invoice_number>/<hash>' => 'invoice/online-payment',
],
],
'cache' => [
'class' => 'yii\caching\FileCache',
],
'mailer' => [
'class' => 'yii\swiftmailer\Mailer',
'transport' => [
'class' => 'Swift_SmtpTransport',
'host' => 'localhost',
],
],
'log' => [
'targets' => [
[
'class' => 'yii\log\FileTarget',
'levels' => ['error', 'warning'],
],
],
],
'db' => require(__DIR__ . '/db.php'),
'crmDb' => require(__DIR__ . '/../crm/config/db.php'),
],
'params' => require(__DIR__ . '/params.php'),
'aliases' => require(__DIR__ . '/aliases.php'),
];
And use the following code for generating the URL;
echo \Yii::$app->getUrlManager()->createUrl(['invoice/online-payment', 'invoice_number' => 'F00001', 'hash' => 'thisIsMyHash']);
It will output ?r=invoice%2Fonline-payment&invoice_number=F00001&hash=thisIsMyHash and not online-betalen/F00001/thisIsMyHash how is this possible.
I am using the same url rules on the frontend application, and there the url is rewrited properly, only in console app’s not.