Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Options for PHP CLI on windows

I'm working with the PHP CLI on windows at the moment to write some small desktop command-line apps.

I wanted to know if and how it may be possible to:

  • Clear the screen (cls would be the normal command but exec() won't work with it)
  • Change the color, change the color of parts of the output (seen this in programs before)
  • Make the command line horizontally bigger - things quickly get unreadable

Is any of the above possible from inside a PHP script?

like image 517
ac2 Avatar asked Mar 14 '26 14:03

ac2


1 Answers

On Windows, in the standard CLI prompt, you cannot output in colour (as in the answer by Spudley).

You can change the size of the window as a user by right-clicking the command window's title bar and selecting Properties, then ammending values in the Layout tab. I do not think it is possible to ammend the width of the CLI within PHP.

You can check the width of the CLI window on Windows using the function I wrote here

like image 110
lyceus Avatar answered Mar 16 '26 02:03

lyceus



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!