Skip to content

如何解决 Laravel 与 Jet 的冲突 #3010

Answered by limingxinleo
panruixin asked this question in Q&A
Discussion options

You must be logged in to vote

原因

让我们编写一个接口,测试这个问题

Route::get('/', function () {
    return get_class(collect());
});

然后我们可以看到结果是 Illuminate\Support\Collection

接下来让我们载入 Jet 组件

composer require hyperf/jet
composer update -o

我们便会看到以下报错

实际报错可能会因 Laravel 版本不同而发生改变

Argument 1 passed to Illuminate\Routing\Router::sortMiddleware() must be an instance of Illuminate\Support\Collection, instance of Hyperf\Utils\Collection given, called in /Users/limingxin/Applications/workspace/php/test/laravel/vendor/laravel/framework/src/Illuminate/Routing/Router.php on line 729

我们打开 vendor/composer/autoload_files.php 文件,便可以看到以下映射关系

以下隐藏其他不相干的文件

'bbeb7603826cb9296dde3ca1a840af47' => $vendorDir . '/hyperf/utils/src/Functions.php',
'265b4fa…

Replies: 3 comments 10 replies

Comment options

You must be logged in to vote
2 replies
@Observer5
Comment options

@limingxinleo
Comment options

Answer selected by limingxinleo
Comment options

You must be logged in to vote
6 replies
@limingxinleo
Comment options

@huangdijia
Comment options

@huangzhhui
Comment options

@huangdijia
Comment options

@huangdijia
Comment options

Comment options

You must be logged in to vote
2 replies
@limingxinleo
Comment options

@Observer5
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
5 participants
Converted from issue

This discussion was converted from issue #3010 on December 24, 2020 04:23.