Back to articles
Exploring the Symfony Tui component

Exploring the Symfony Tui component

via Dev.todavid duymelinck

I had seen the Symfony Tui component announcement , but I just got the time to start to explore it. Setup To explore the component fast I checked out the PR. Added "App\\" : "src/App" to composer.json. Created a command, TuiTestCommand, in the App directory, and a bin/console file with a console application and the command. In the following sections I'm going to take baby steps to understand how the component works. Returning a text The standard way to return a text is $output->writeln('Hello world!'); To do this with the Tui component this is: use Symfony\Component\Tui\Tui ; use Symfony\Component\Tui\Widget\TextWidget ; // in the command $tui = new Tui (); $tui -> add ( new TextWidget ( 'Hello World!' )); $tui -> onTick ( fn () => $tui -> stop ()); $tui -> run (); Because the component is meant to create rich interactive experiences it uses a bit more code to make it run. You can look at the Tui class as an agent. You can give it rules and when called it runs those rules. Do I have AI

Continue reading on Dev.to

Opens in a new tab

Read Full Article
3 views

Related Articles