I'm using XAMPP to build a Drupal 9 project so I start here C:\xampp\htdocs and create a folder for my D9 site, i.e. 'myd9site'. Using XAMPP's Shell command tool, navigate to the 'htdocs' folder and run:
composer create-project --no-install drupal/recommended-project myd9site
This only loads the composer.json and composer.lock files but allows you to tweak a few things in composer.json before you create all of the main files. For example, I prefer to have my site files at root level rather then in a 'web' folder. To do this I change the sub-directory from 'web/' to './'. The keys to modify are the 'extra' sub-keys 'webroot' and 'installer-paths,. i.e. Find/replace "web/" with "./".
Here is the original code:
"extra": { "drupal-scaffold": { "locations": { "web-root": "web/" } }, "installer-paths": { "web/core": [ "type:drupal-core" ], "web/libraries/{$name}": [ "type:drupal-library" ], "web/modules/contrib/{$name}": [ "type:drupal-module" ], "web/profiles/contrib/{$name}": [ "type:drupal-profile" ], "web/themes/contrib/{$name}": [ "type:drupal-theme" ], "drush/Commands/contrib/{$name}": [ "type:drupal-drush" ], "web/modules/custom/{$name}": [ "type:drupal-custom-module" ], "web/profiles/custom/{$name}": [ "type:drupal-custom-profile" ], "web/themes/custom/{$name}": [ "type:drupal-custom-theme" ] },
Here is the code after the find/replace "web/" with "./".
"extra": { "drupal-scaffold": { "locations": { "web-root": "./" } }, "installer-paths": { "./core": [ "type:drupal-core" ], "./libraries/{$name}": [ "type:drupal-library" ], "./modules/contrib/{$name}": [ "type:drupal-module" ], "./profiles/contrib/{$name}": [ "type:drupal-profile" ], "./themes/contrib/{$name}": [ "type:drupal-theme" ], "drush/Commands/contrib/{$name}": [ "type:drupal-drush" ], "./modules/custom/{$name}": [ "type:drupal-custom-module" ], "./profiles/custom/{$name}": [ "type:drupal-custom-profile" ], "./themes/custom/{$name}": [ "type:drupal-custom-theme" ] },
Also think about changing "minimum-stability": "stable" to "minimum-stability": "dev"
Once done, if still in the 'htdocs' folder, navigate to your site folder cd myd9site and run composer install and composer with use the composer.json to create the site files.
In D9 Drush is added with composer require so lets do that next. Run:
composer require drush/drush
I'm sure there is a better method, but when I want to run a Drush command I need to navigate to the 'vendor/bin' folder. i.e. cd vendor/bin and then I can run drush status and you should see some stats for the Drupal version, etc. If I want to run another composer command I just go back a couple of folders i.e. cd ../../.
You should be able to open up a browser and go to http://localhost/myd9site and the default Druapl install will start allowing you to set up a database in XAMPP's phpMyAdmin and enter the details when prompted.
With any luck, you now have a new D9 site setup using composer and XAMPP.