I am attempting to write a PHP script that I would like to run from the command line. I want to use composer to manage its dependencies, as well as to make it available to be installed as a dependency to other projects. I also want to maintain the ability to use it on its own (with its dependencies).
main.php is my "entry point" (what I would execute from the command line). As I built and tested it, I did so in the "stand alone" mindset. A such,
main.php gets loads autoload like so:
Continuing in stand alone mindset, I set it up like so:
git clone package into place
This produces the following directory setup"
This works well--I can run
php src/main.php which is able to find the classes it needs because it loads
Where I run in to trouble is when I want to install the package as a dependency to another project (in order to have the script available to run there). I add my package to the
composer.json and it gets installed. Attempting to run
php vendor/compnay/package/src/main.php fails, however, because the necessary
autoload.php is in a different place: