Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PHP Fatal Error Monolog/PSR Version Incompatibility #59

Open
laflier opened this issue May 10, 2024 · 1 comment
Open

PHP Fatal Error Monolog/PSR Version Incompatibility #59

laflier opened this issue May 10, 2024 · 1 comment

Comments

@laflier
Copy link

laflier commented May 10, 2024

Description

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 /Users/len/Sites/dev.bookdiscovery.mamp/wp-content/composer/vendor/monolog/monolog/src/Monolog/Logger.php on line 681

Steps to reproduce

Install typesense-php with composer
use Typesense/Client
$client = new Client()

Expected Behavior

No errors

Actual Behavior

Fatal error

Metadata

**PHP Version: 8.1

Typesense Version: 26

OS: Ubuntu 24.01

@laflier
Copy link
Author

laflier commented May 11, 2024

The problem turned out to be related to the versions of monolog and psr installed by composer. Apparently there is an issue with monolog 3+. These threads were helpful in diagnosing:

composer/composer#11246
https://stackoverflow.com/questions/75696889/fatal-error-declaration-of-monolog-loggeremergencystringablestring-message

The solution was to downgrade monolog and psr. I accomplished this by adding the following lines to the composer.json file in the project root:

"monolog/monolog": "^2.5",
"psr/log": "^2.0"

I then updated monolog and psr with the following composer command (composer required simultaneous update of monolog and psr for this operation):

composer update monolog/monolog psr/log

This operation successfully downgraded monolog from version 3.6.0 to version 2.9.3 and psr from version 3.0.0 to version 2.0.0. The TypeSense PHP client is now working.

@laflier laflier changed the title PHP Fatal Error PHP Fatal Error Monolog/PSR Version Incompatibility May 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant