PHP Fatal error: Declaration of Monolog\Logger::emergency(Stringable|string

We are getting this error when activating WP RSS Aggregator plugin in bedrock + sage theme development. Just confuse why Monolog and PSR/log are conflicting within the sage theme.

PHP **Fatal** **error:** Declaration of Monolog\Logger::emergency(Stringable|string $message, array $context = []): void must be compatible with Psr\Log\LoggerInterface::emergency($message, array $context = []) in /var/www/html/sage/web/app/themes/sage-pivotal/vendor/monolog/monolog/src/Monolog/Logger.php on line 682
[15-Oct-2024 06:58:09 UTC] PHP **Fatal** **error:** Uncaught **Error**: Class "Monolog\Logger" not found in /var/www/html/sage/web/app/themes/sage-pivotal/vendor/monolog/monolog/src/Monolog/Handler/AbstractHandler.php:60
Stack trace:
#0 /var/www/html/sage/web/app/themes/sage-pivotal/vendor/monolog/monolog/src/Monolog/Handler/AbstractHandler.php(38): Monolog\Handler\AbstractHandler->setLevel(Object(Monolog\Level))
#1 /var/www/html/sage/web/app/themes/sage-pivotal/vendor/monolog/monolog/src/Monolog/Handler/StreamHandler.php(49): Monolog\Handler\AbstractHandler->__construct(Object(Monolog\Level), true)
#2 /var/www/html/sage/web/app/themes/sage-pivotal/vendor/illuminate/log/LogManager.php(187): Monolog\Handler\StreamHandler->__construct('/var/www/html/s...', Object(Monolog\Level))
#3 /var/www/html/sage/web/app/themes/sage-pivotal/vendor/illuminate/log/LogManager.php(141): Illuminate\Log\LogManager->createEmergencyLogger()
#4 /var/www/html/sage/web/app/themes/sage-pivotal/vendor/illuminate/log/LogManager.php(124): Illuminate\Log\LogManager->get('stack')
#5 /var/www/html/sage/web/app/themes/sage-pivotal/vendor/illuminate/log/LogManager.php(681): Illuminate\Log\LogManager->driver()
#6 /var/www/html/sage/web/app/themes/sage-pivotal/vendor/roots/acorn/src/Illuminate/Foundation/Exceptions/Handler.php(317): Illuminate\Log\LogManager->error('Class "Monolog\\...', Array)
#7 /var/www/html/sage/web/app/themes/sage-pivotal/vendor/roots/acorn/src/Illuminate/Foundation/Exceptions/Handler.php(278): Illuminate\Foundation\Exceptions\Handler->reportThrowable(Object(Error))
#8 /var/www/html/sage/web/app/themes/sage-pivotal/vendor/roots/acorn/src/Illuminate/Foundation/Bootstrap/HandleExceptions.php(183): Illuminate\Foundation\Exceptions\Handler->report(Object(Error))
#9 [internal function]: Illuminate\Foundation\Bootstrap\HandleExceptions->handleException(Object(Error))
#10 {main}
  thrown in /var/www/html/sage/web/app/themes/sage-pivotal/vendor/monolog/monolog/src/Monolog/Handler/AbstractHandler.php on line 60`

You will have to reach out to the plugin developers and ask them to namespace their dependencies. You can add a link to Compatibility | Acorn Docs | Roots “Plugin developers need to wrap their dependencies with their own namespace…”

In the meantime you might get away with commenting out a reference to psr/log. This is the temporary solution for WPML, you can adjust it to your needs: https://discourse.roots.io/t/solved-acorn-v3-v4-upgrade-psr-logger-issue-bedrock-wpml-fatal-error-declaration-of-monolog-logger-emergency/26987/7?u=tombro

I can see they also require psr/container and some symfony requirements which might also be incompatible.

1 Like

Thanks for the quick response… I will definitely communicate with the plugin author.