Score:0

PHP Error: Drush\Application::setLogger(Psr\Log\LoggerInterface $logger) must be compatible in two given files | How to fix this error?

lc flag

I was trying to setup a local environment of a website created on Acquia cloud platform. Everything was done properly including the database import. But now, when I execute drush commands, it gives me the following error.

PHP Fatal error: Declaration of Drush\Application::setLogger(Psr\Log\LoggerInterface $logger) must be compatible with Psr\Log\LoggerAwareInterface::setLogger(Psr\Log\LoggerInterface $logger): void in C:\xampp\htdocs\pk-new\vendor\psr\log\Psr\Log\LoggerAwareTrait.php on line 22

I tried to rectify this by finding a solution online. The solution I found was to include :void in the function definition of the file throwing the error. After saving this, when I tried to run the drush commands it threw another error.

This time it was related to the $message variable not being compatible in two files. I tried to find the solution to this but then after fixing that it threw another error of the same type. I believe there is a right way to fix this without playing with the core files.

Is this a problem related to drush being globally installed? I am not too sure of that and also on how to go about it if that is the case.

I had done this type of an export in the past and it worked just fine, but now it is not. I feel that the compatibility of drush and php version might be causing problems. The version I have are:

Drush - 11.4.0
PHP 8.1.14

Please let me know if there is a way to fix this issue. And if not, whether this issue will create problems while working on the website in the future.

Thank you!

techenzie avatar
lc flag
Yes, I did check this post out. This is the solution that did not workout for me as mentioned in the my question. I did not understand this particular solution given in that post though: https://drupal.stackexchange.com/a/313250/109197
leymannx avatar
ne flag
Execute `vendor/drush/drush/drush cr`, does the error persist? Add a sample command to your question. Is Drush Launcher involved?
techenzie avatar
lc flag
No, the error did not appear when I executed ```vendor/drush/drush/drush cr```. But it does appear when I execute ```drush cr```. No, drush launcher is not involved as far as I know
4uk4 avatar
cn flag
Follow this answer https://drupal.stackexchange.com/a/313491/47547 and uninstall Drush globally. Run `which drush` to find the location of the globally installed Drush. Then you can install [Drush Launcher](https://github.com/drush-ops/drush-launcher) so that you don't need to type the path to the local Drush every time.
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.