Symfony News

New in Symfony 4.3: Console Hyperlinks

Symfony 4.3 will be released in May 2019. This is the first article of the series that shows the most important new features introduced by this Symfony version.


Gabriel Ostroluck√Ĺ

Contributed by
Gabriel Ostroluck√Ĺ
in #29168.

Creating advanced Console interfaces is important for lots of applications, even those which are not Console based but include some commands to perform certain tasks.

Rendering clickable hyperlinks is one of the most important missing features of Console apps and commands. Although most of the terminal emulators auto-detect URLs and allow to click on them with some key combination, it's not not possible to render clickable text that points to some arbitrary URL.

However, some terminal emulators led by iTerm2 and GNOME Terminal, are working on a new specification to add support for this feature. That's why Symfony 4.3 added support for hyperlinks in the Console using the following syntax:

1
2
3
// hyperlink syntax: <href=THE_LINK_URL> THE_LINK_TEXT </>
$output->writeln('<href=https://symfony.com>Symfony Homepage</>');
$output->writeln('<href=https://github.com/symfony/symfony/issues/29585>View Issue</>');

If your terminal emulator is compatible, this is how you'll see these links:

Thanks to this new feature, we've started to improve the developer experience of some Symfony features, such as the links displayed in the VarDumper console output.

Before using this feature in your own apps and commands, check out the growing list of terminal emulators that support hyperlinks to see if your terminal has already added support for it.


Be trained by Symfony experts - 2019-01-8 Clichy - 2019-01-14 Clichy - 2019-01-14 Clichy


About us

What a Symfony developer should know about the framework: News, Jobs, Tweets, Events, Videos,...

Find us on Twitter

Find us on Facebook

ADS