I'm developing a PHP package (distributed on Composer) that could benefit from logging, but doesn't require it. I've seen many sample composer.json
files that include suggested packages like so:
{
"suggest": {
"monolog/monolog": "Allows more advanced logging of the application flow"
}
}
How would I go about detecting if the library is available at runtime? I want to instantiate a default instance of the \Monolog\Logger
if it is available, allow the consumer of the package to pass in their own Psr\Log\LoggerInterface
interface implementation if they desire. Are there any best practices around this?