目录
3、更新 composer 的 autoload_files.php 文件
1.Your requirements could not be resolved to an installable set of packages.
问题:PHP Fatal error: Declaration of Psr\Log\LoggerInterface\Proxy::emergency($message, array $context)
更新到magento 2.4.2 错误提示:PHP Fatal error: Declaration of Psr\Log\LoggerInterface\Proxy::emergency($message, array $context)
PHP Fatal error: Declaration of Psr\Log\LoggerInterface\Proxy::emergency($message, array $context) must be compatible with Psr\Log\LoggerInterface::emergency($message, array $context = Array) in /www/wwwroot/magento/generated/code/Psr/Log/LoggerInterface/Proxy.php on line 7
这是由于PHP版本问题,参考https://github.com/jbboehr/php-psr/issues/78
修改generated/code/Psr/Log/LoggerInterface/Proxy.php代码只能临时解决,只要刷新后文件就会被恢复,不能解决问题
官网安装说明要PHP7.4.0版本:https://devdocs.magento.com/guides/v2.4/install-gde/system-requirements.html ,哪就先更新PHP吧参考 ubuntu 20 php-7.4.15 编译安装
编译安装好后测试了好几个版本还是不行,不能再耗下去了,先临时写个类来解决问题。
解决办法
1、在app目录下新建psrfix.php文件
内容如下:参考https://github.com/jbboehr/php-psr/issues/78#issuecomment-722290110
<?php
namespace Psr\Log\LoggerInterface;
/**
* Proxy class for @see \Psr\Log\LoggerInterface
*/
class Proxy implements \Psr\Log\LoggerInterface, \Magento\Framework\ObjectManager\NoninterceptableInterface
{
/**
* Object Manager instance
*
* @var \Magento\Framework\ObjectManagerInterface
*/
protected $_objectManager = null;
/**
* Proxied instance name
*
* @var string
*/
protected $_instanceName = null;
/**
* Proxied instance
*
* @var \Psr\Log\LoggerInterface
*/
protected $_subject = null;
/**
* Instance shareability flag
*
* @var bool
*/
protected $_isShared = null;
/**
* Proxy constructor
*
* @param \Magento\Framework\ObjectManagerInterface $objectManager
* @param string $instanceName
* @param bool $shared
*/
public function __construct(\Magento\Framework\ObjectManagerInterface $objectManager, $instanceName = '\\Psr\\Log\\LoggerInterface', $shared = true)
{
$this->_objectManager = $objectManager;
$this->_instanceName = $instanceName;
$this->_isShared = $shared;
}
/**
* @return array
*/
public function __sleep()
{
return ['_subject', '_isShared', '_instanceName'];
}
/**
* Retrieve ObjectManager from global scope
*/
public function __wakeup()
{
$this->_objectManager = \Magento\Framework\App\ObjectManager::getInstance();
}
/**
* Clone proxied instance
*/
public function __clone()
{
$this->_subject = clone $this->_getSubject();
}
/**
* Get proxied instance
*
* @return \Psr\Log\LoggerInterface
*/
protected function _getSubject()
{
if (!$this->_subject) {
$this->_subject = true === $this->_isShared
? $this->_objectManager->get($this->_instanceName)
: $this->_objectManager->create($this->_instanceName);
}
return $this->_subject;
}
/**
* {@inheritdoc}
*/
public function emergency($message, array $context = [])
{
return $this->_getSubject()->emergency($message, $context);
}
/**
* {@inheritdoc}
*/
public function alert($message, array $context = [])
{
return $this->_getSubject()->alert($message, $context);
}
/**
* {@inheritdoc}
*/
public function critical($message, array $context = [])
{
return $this->_getSubject()->critical($message, $context);
}
/**
* {@inheritdoc}
*/
public function error($message, array $context = [])
{
return $this->_getSubject()->error($message, $context);
}
/**
* {@inheritdoc}
*/
public function warning($message, array $context = [])
{
return $this->_getSubject()->warning($message, $context);
}
/**
* {@inheritdoc}
*/
public function notice($message, array $context = [])
{
return $this->_getSubject()->notice($message, $context);
}
/**
* {@inheritdoc}
*/
public function info($message, array $context = [])
{
return $this->_getSubject()->info($message, $context);
}
/**
* {@inheritdoc}
*/
public function debug($message, array $context = [])
{
return $this->_getSubject()->debug($message, $context);
}
/**
* {@inheritdoc}
*/
public function log($level, $message, array $context = [])
{
return $this->_getSubject()->log($level, $message, $context);
}
}
2、修改composer.json
...
"autoload": {
...
"files": [
"app/etc/NonComposerComponentRegistration.php",
"app/psrfix.php"
],
...
3、更新 composer 的 autoload_files.php 文件
composer dump-autoload
更新Magento2.4.2时一些坑的修复记录:
1.Your requirements could not be resolved to an installable set of packages.
运行composer update 提示Your requirements could not be resolved to an installable set of packages.
查看magento/magento2-functional-testing-framework新版本
composer show magento/magento2-functional-testing-framework 3.*.* --all | grep -m 1 versions
打开composer.json修改magento/magento2-functional-testing-framework版本成3.2.1
2.composer update更新一直没有反应
composer update
发现更新一直没有反应,ctrl+c结束进程加-vvv的方式来运行
composer update -vvv
我这里有发现因为friendsofphp/php-cs-fixer导致一直重试。试了几个版本多不行,后改成^2.14.0可以过了