We can't find the internet
Attempting to reconnect
Something went wrong!
Hang in there while we get back on track
If you want to output a text in the console using Laravel and make it a clickable hyperlink, you can easily do it like this:
namespace App\Console\Commands;
use Illuminate\Console\Command;
class SampleCommand extends Command
{
protected $signature = 'sample';
protected $description = 'Prints a text with a hyperlink to the console';
public function handle(): int
{
$this->info('<href=https://www.yellowduck.be>hello world</>');
return self::SUCCESS;
}
}
You can also use it to color the output by adding:
$this->info('<bg=yellow;fg=red;href=https://www.yellowduck.be>hello world</>');
The syntax is really simple:
bg
: background colorfg
: foreground colorhref
: a hyperlink
The Symfony module behind this is what makes this work.
If this post was enjoyable or useful for you, please share it! If you have comments, questions, or feedback, you can email my personal email. To get new posts, subscribe use the RSS feed.