How to port a PHP application that uses Composer?

From: Mel Pilgrim <list_freebsd_at_bluerosetech.com>
Date: Tue, 17 May 2022 02:31:37 UTC
Composer is a github-centric dependency management tool for PHP 
applications.  It works very well on its own, but I'm having trouble 
figuring out how to integrate it with pkg building.

The composer workflow is:

1. Clone the PHP application repo, which has a composer.json file
2. Download composer.phar and run `php composer.phar ...`
3. Composer examines composer.json and downloads dependencies from other 
github repos
4. Composer creates an autoloader script that does all of the require 
calls for the dependencies

The problem is that download and autoloader script part.  If I ran it as 
part of the pkg building process, there's a fetch-extract race as it 
needs network access, but also a file extracted from the distfile.

If I left it to user config, the autoloader script creation will change 
a file managed by pkg.

So how do I do this? Can a composer-using PHP application be ported?