I try to send some emails with a CLI command with php artisan of Laravel, something easy like :
php artisan invitation:send [email protected]
This command is calling a UserController method which contains :
Mail::send('emails.beta.invitation', $data, function($message) use ($address)
{
$message->to($address)
->subject('My subject');
});
The problem is that when it creates the HTML using the view, all references to URL::asset('img/foo.png')
in the template gives me a beautiful :
http://localhost/img/foo.png
instead of the website url :
http://mydomain.com/img/foo.png
If I call this method by calling it in the web browser, there is the good URI for the asset.
I even tried with an environment to the CLI but it doesn't work. (ie. --env=production
)
Where am I wrong ?
The Laravel PHP artisan serve command helps running applications on the PHP development server. As a developer, you can use Laravel artisan serve to develop and test various functions within the application. It also accepts two additional options. You can use the host for changing application's address and port.
{{url}} allows you to create a link to a URL on your site -- another benefit is the fact that you can set the second parameter to an array with query string parameters within. {{asset} simply allows you to link to an asset within your public directory -- for example css/main.
All right, I got it.
When using the CLI, Laravel is using the config file app/config/app.php
to read the 'url' (default 'url' => 'http://localhost'
).
So I just had to create a new config file under app/config/local/app.php
with :
<?php
return array(
'url' => 'http://localhost:8000',
);
And to change the app/config/app.php
with my production value :
'url' => 'http://mydomain.com'
Now it works well !
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With