Using composer init
Cheat sheet for using composer init to create your composer.json.
https://getcomposer.org/doc/03-cli.md#init
Do not run this as root. Normally. The exception being when working on the system wide packages, which can actually be avoided by setting everything up as a lowbie user and then flicking over the owner. See Install Composer system-wide packages for details.
composer init \ --no-interaction \ --name "root/test" \ --description "A test of the system" \ --author "Ted <john@example.com>" \ --type project \ --require "hirak/prestissimo:^0.3.9" \ --stability "stable" \ --license "GPL-2.0-or-later"