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.
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 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.
If your terminal does not support hyperlinks, they will be rendered as normal and non-clickable text and you won't see their URLs. That's why it's recommended to check out the growing list of terminal emulators that support hyperlinks before using this feature in your own apps and commands.
New in Symfony 4.3: Console Hyperlinks symfony.com/blog/new-in-symfony-4-3-console-hyperlinksTweet this
Become a certified developer! Exams are online and available in all countries.Register Now
Comments are closed.
To ensure that comments stay relevant, they are closed for old posts.