使用 ralphjsmit/laravel-horizon-cron-supervisor 包时出现 BadMethodCallException

问题描述 投票:0回答:1

当我更新我的项目(撰写更新)时,我收到下一个错误:

$ composer update
...
> Illuminate\Foundation\ComposerScripts::postAutoloadDump
> @php artisan package:discover --ansi

   BadMethodCallException 

  Method Illuminate\Console\Scheduling\Event::tap does not exist.

  at vendor/laravel/framework/src/Illuminate/Macroable/Traits/Macroable.php:113
    109▕      */
    110▕     public function __call($method, $parameters)
    111▕     {
    112▕         if (! static::hasMacro($method)) {
  ➜ 113▕             throw new BadMethodCallException(sprintf(
    114▕                 'Method %s::%s does not exist.', static::class, $method
    115▕             ));
    116▕         }
    117▕ 

  • Bad Method Call: Did you mean Illuminate\Console\Scheduling\Event::at() ? 

      +7 vendor frames 
  8   artisan:35
      Illuminate\Foundation\Console\Kernel::handle()

在 laravel.log 中我们发现了这个堆栈跟踪:

[2024-10-23 12:33:45] production.ERROR: Method Illuminate\Console\Scheduling\Event::tap does not exist. {"exception":"[object] (BadMethodCallException(code: 0): Method Illuminate\\Console\\Scheduling\\Event::tap does not exist. at .../vendor/laravel/framework/src/Illuminate/Macroable/Traits/Macroable.php:113)
[stacktrace]
#0 .../vendor/ralphjsmit/laravel-horizon-cron-supervisor/src/Supervisor/SupervisorServiceProvider.php(26): Illuminate\\Console\\Scheduling\\Event->__call()

如果我们查看代码行,然后再查看Event类,我们找不到tap方法。

我的撰写文件:

{
    "name": "laravel/laravel",
    "type": "project",
    "description": "The Laravel Framework.",
    "keywords": ["framework", "laravel"],
    "license": "MIT",
    "require": {
        "php": "^8.1",
        "fideloper/proxy": "^4.4",
        "fruitcake/laravel-cors": "^2.0",
        "guzzlehttp/guzzle": "^7.3",
        "inspector-apm/inspector-laravel": "^4.7",
        "laravel/framework": "^8.54",
        "laravel/horizon": "^5.7",
        "laravel/tinker": "^2.5",
        "predis/predis": "^2.1.1",
        "ralphjsmit/laravel-horizon-cron-supervisor": "^1.0.1",
        "tymon/jwt-auth": "dev-develop"
    },
    "require-dev": {
        "facade/ignition": "^2.5",
        "fakerphp/faker": "^1.9.1",
        "laravel/breeze": "^1.6",
        "laravel/sail": "^1.0.1",
        "mockery/mockery": "^1.4.2",
        "nunomaduro/collision": "^5.0",
        "phpunit/phpunit": "^9.3.3"
    },
    "autoload": {
        "psr-4": {
            "App\\": "app/",
            "Database\\Factories\\": "database/factories/",
            "Database\\Seeders\\": "database/seeders/"
        }
    },
    "autoload-dev": {
        "psr-4": {
            "Tests\\": "tests/"
        }
    },
    "scripts": {
        "post-autoload-dump": [
            "Illuminate\\Foundation\\ComposerScripts::postAutoloadDump",
            "@php artisan package:discover --ansi"
        ],
        "post-root-package-install": [
            "@php -r \"file_exists('.env') || copy('.env.example', '.env');\""
        ],
        "post-create-project-cmd": [
            "@php artisan key:generate --ansi"
        ]
    },
    "extra": {
        "laravel": {
            "dont-discover": []
        }
    },
    "config": {
        "optimize-autoloader": true,
        "preferred-install": "dist",
        "sort-packages": true
    },
    "minimum-stability": "dev",
    "prefer-stable": true
}

综上所述,运行composer update时,会出现BadMethodCallException,因为Illuminate\Console\Scheduling\Event类中不存在方法tap。此问题由 ralphjsmit/laravel-horizon-cron-supervisor 包引起,该包调用了 Event 类中不存在的方法。正如 Event 类文档中所示,tap 方法不是 Laravel 框架的一部分。错误跟踪指向 SupervisorServiceProvider.php 文件中的调用

其他人也遇到过这种情况吗?谢谢。

php laravel exception package
1个回答
0
投票

查看了源代码文件的提交历史后,我将library版本从1.4.0降级到1.3.0,然后更新项目时没有报错。

© www.soinside.com 2019 - 2024. All rights reserved.