-
Book Overview & Buying
-
Table Of Contents
The Art of Modern PHP 8
By :
It is quite common for a person to want to provide some kind of executable with their Composer package.
You will probably have noticed that, when installing some packages, Composer not only creates the source folders and files under vendor but also creates a bin or vendor/bin directory (depending on how you have things configured) that contains all the executable files that your dependencies provide.
It is definitely worth reading the official documentation on this:
https://getcomposer.org/doc/articles/vendor-binaries.md
For our HelloWorld package, we have an executable defined that provides the mission-critical functionality of our package:
composer-module-hello-world/bin/hello
Repo: https://git.io/JRw5R
#!/usr/bin/env php
<?php
declare(strict_types=1);
/**
* Handle the fact that you may be executing this from your own package,
* or as an installed dependency
*/
$autoloaderPath = (static function (): string {
...