PHP Fatal error: Declaration of Hyperf\Framework\SymfonyEventDispatcher::dispatch($event) must be c

 事情的经过是这样的:

 一、我闲着没事更新了一下依赖

composer update

 批量更新,控制台大概是这样的,更新了一大堆,这下尴尬了

bash-4.4# composer update
Do not run Composer as root/super user! See https://getcomposer.org/root for details
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 1 install, 28 updates, 1 removal
  - Removing symfony/polyfill-php73 (v1.15.0)
  - Updating composer/package-versions-deprecated (1.4.2 => 1.8.0): Downloading (100%)
  - Updating hyperf/utils (v1.1.26 => v1.1.27): Downloading (100%)
  - Updating hyperf/framework (v1.1.26 => v1.1.27): Downloading (100%)
  - Updating phpdocumentor/reflection-common (2.0.0 => 2.1.0): Downloading (100%)
  - Updating hyperf/rpc-client (v1.1.26 => v1.1.27): Downloading (100%)
  - Updating symfony/finder (v4.4.7 => v4.4.8): Downloading (100%)
  - Installing symfony/contracts (v1.1.0): Downloading (100%)
  - Downgrading symfony/console (v4.4.7 => v4.2.12): Downloading (100%)
  - Updating hyperf/devtool (v1.1.26 => v1.1.27): Downloading (100%)
  - Updating symfony/debug (v4.4.7 => v4.4.8): Loading from cache
  - Updating symfony/translation (v5.0.7 => v5.0.8): Downloading (100%)
  - Updating illuminate/contracts (v6.18.10 => v6.18.11): Loading from cache
  - Updating illuminate/support (v6.18.10 => v6.18.11): Loading from cache
  - Updating illuminate/filesystem (v6.18.10 => v6.18.11): Loading from cache
  - Updating illuminate/container (v6.18.10 => v6.18.11): Loading from cache
  - Updating illuminate/events (v6.18.10 => v6.18.11): Loading from cache
  - Updating illuminate/view (v6.18.10 => v6.18.11): Loading from cache
  - Updating symfony/event-dispatcher-contracts (v1.1.7 => v2.0.1): Downloading (100%)
  - Updating symfony/event-dispatcher (v4.4.7 => v5.0.8): Downloading (100%)
  - Updating symfony/options-resolver (v5.0.7 => v5.0.8): Downloading (100%)
  - Updating symfony/process (v5.0.7 => v5.0.8): Downloading (100%)
  - Updating symfony/stopwatch (v5.0.7 => v5.0.8): Downloading (100%)
  - Updating symfony/inflector (v5.0.7 => v5.0.8): Loading from cache
  - Updating symfony/property-access (v4.4.7 => v4.4.8): Downloading (100%)
  - Updating symfony/serializer (v4.4.7 => v4.4.8): Downloading (100%)
  - Updating jean85/pretty-package-versions (1.2 => 1.3.0): Downloading (100%)
  - Updating symfony/filesystem (v5.0.7 => v5.0.8): Downloading (100%)
  - Updating symfony/config (v5.0.7 => v5.0.8): Downloading (100%)
  - Updating symfony/dependency-injection (v5.0.7 => v5.0.8): Downloading (100%)
symfony/contracts suggests installing psr/cache (When using the Cache contracts)
symfony/contracts suggests installing symfony/cache-contracts-implementation
symfony/contracts suggests installing symfony/http-client-contracts-implementation
symfony/contracts suggests installing symfony/service-contracts-implementation
symfony/contracts suggests installing symfony/translation-contracts-implementation

二、然后启动时,报错了

 启动命令

php bin/hyperf.php start

 报错如下

PHP Fatal error:  Declaration of Hyperf\Framework\SymfonyEventDispatcher::dispatch($event) must be compatible with 
Symfony\Contracts\EventDispatcher\EventDispatcherInterface::dispatch(object $event, ?string $eventName = NULL): 
object in /hyperf-skeleton/vendor/hyperf/framework/src/SymfonyEventDispatcher.php on line 23

Fatal error: Declaration of Hyperf\Framework\SymfonyEventDispatcher::dispatch($event) must be compatible with 
Symfony\Contracts\EventDispatcher\EventDispatcherInterface::dispatch(object $event, ?string $eventName = NULL): 
object in /hyperf-skeleton/vendor/hyperf/framework/src/SymfonyEventDispatcher.php on line 23

 好像是什么奇怪的地方冲突了

三、解决办法

 经一位前辈指点,说这个问题他也遇到过,官网上有解决办法。

hyperf官网 常见问题

截图如下

PHP Fatal error: Declaration of Hyperf\Framework\SymfonyEventDispatcher::dispatch($event) must be c_第1张图片

命令如下

rm -rf vendor
rm -rf composer.lock
composer require "symfony/event-dispatcher:^4.3"

按顺序执行,冲突解决了,启动  php bin/hyperf.php start 成功,又能愉快的玩耍了。

 

你可能感兴趣的:(#,Hyperf,hyperf)