Tomas Votruba has a new post to his site sharing five "gotchas" in CLI applications as it relates to the "bin" file.
This post from Master PHP CLI Apps with Symfony cluster will focus on bin files. It's the smallest part of PHP CLI Application, so I usually start with it.Yet, there are still a few blind paths you can struggle with. I'll drop a few extra tricks to make your bin file clean and easy to maintain.
He starts with a brief definition of what a "bin" file is before getting into his list of "gotchas":
- recommendations about naming and location of the file
- setting it up to be autoloaded by Composer
- including the right "shebang" to have it executed by the correct program
- changing access rights
- symlinking in Composer
The post ends with the complete code required to build a simple Symfony CLI application that will autoload libraries correctly and be executable by the system's php
binary.