0

There are console programs, like an editor (say: nano for example) or like a system monitor (say: htop) where you can "navigate" with arrows and freely interact with the content.

In this example, for example I have executed htop and while it's running I've pressed arrow-down multiple times until the PID 14 has been selected:

htop with PID 14 selected

In Symfony I can easily print and also format with colors with the OutputInterface that is injected into the commands.

But... can this "interactivity" be achieved easily with PHP and symfony console commands?

For the sake of the example: Could I code a simple "snake" game in PHP/symfony/console?

(PD: If needed, I MAY use ReactPhp to handle the event loop).

Thomas Dickey
  • 51,086
  • 7
  • 70
  • 105
Xavi Montero
  • 9,239
  • 7
  • 57
  • 79

1 Answers1

0

Yes, you can! This is an excellent use case for ReactPHP, especially if you're looking to create something interactive and reactive. I highly recommend checking out https://github.com/clue/reactphp-stdio, as it perfectly fits your use case.

  • Have you personally tried to code with clue/reactphp-stdio yourself? – Xavi Montero Aug 01 '23 at 10:21
  • Interesting article. I also like to use it but I cannot see how to implement it with symfony and twig template. Can someone give a documentation or an example? – Adi Aug 18 '23 at 14:08