流明5.7.5打破绑定分辨率

时间:2018-11-15 16:36:30

标签: php laravel ioc-container lumen

更新

See my answer

流明版本:5.7.5

PHP版本:7.2

我刚刚完成了从5.5到5.6到5.7的升级,直到我将5.7.5升级到5.7.4为止,一切都按预期进行。 PHP Artisan给了我

“目标[Illuminate \ Contracts \ Debug \ ExceptionHandler]无法实例化。”

示例:

PHP工匠

在Container.php第945行中:

目标[Illuminate \ Contracts \ Debug \ ExceptionHandler]无法实例化。 重现步骤: 从5.5升级到5.6到5.7,最终从5.7.4升级到5.7.5。

我正在检查所有代码更改以及可能导致此问题的原因。

也许你们有个主意吗?

这是堆栈跟踪:

[2018-11-15 15:30:50] local.ERROR: Illuminate\Contracts\Container\BindingResolutionException: Target [Illuminate\Contracts\Debug\ExceptionHandler] is not instantiable. in /project/vendor/illuminate/container/Container.php:945
Stack trace:
0 project/vendor/illuminate/container/Container.php(785): Illuminate\Container\Container->notInstantiable('Illuminate\\Cont...')
1 project/vendor/illuminate/container/Container.php(658): Illuminate\Container\Container->build('Illuminate\\Cont...')
2 project/vendor/illuminate/container/Container.php(609): Illuminate\Container\Container->resolve('Illuminate\\Cont...', Array)
3 project/vendor/laravel/lumen-framework/src/Application.php(260): Illuminate\Container\Container->make('Illuminate\\Cont...', Array)
4 project/vendor/illuminate/container/Container.php(1222): Laravel\Lumen\Application->make('Illuminate\\Cont...')
5 project/vendor/laravel/lumen-framework/src/Console/Kernel.php(223): Illuminate\Container\Container->offsetGet('Illuminate\\Cont...')
#6 project/vendor/laravel/lumen-framework/src/Console/Kernel.php(117): Laravel\Lumen\Console\Kernel->reportException(Object(Illuminate\Contracts\Container\BindingResolutionException))
#7 project/artisan(43): Laravel\Lumen\Console\Kernel->handle(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#8 {main} {"exception":"[object] (Illuminate\\Contracts\\Container\\BindingResolutionException(code: 0): Target [Illuminate\\Contracts\\Debug\\ExceptionHandler] is not instantiable. at project/vendor/illuminate/container/Container.php:945)
#[stacktrace]
#0 project/vendor/illuminate/container/Container.php(785): Illuminate\\Container\\Container->notInstantiable('Illuminate\\\\Cont...')
#1 project/vendor/illuminate/container/Container.php(658): Illuminate\\Container\\Container->build('Illuminate\\\\Cont...')
#2 project/vendor/illuminate/container/Container.php(609): Illuminate\\Container\\Container->resolve('Illuminate\\\\Cont...', Array)
#3 project/vendor/laravel/lumen-framework/src/Application.php(260): Illuminate\\Container\\Container->make('Illuminate\\\\Cont...', Array)
#4 project/vendor/illuminate/container/Container.php(1222): Laravel\\Lumen\\Application->make('Illuminate\\\\Cont...')
#5 project/vendor/laravel/lumen-framework/src/Console/Kernel.php(223): Illuminate\\Container\\Container->offsetGet('Illuminate\\\\Cont...')
#6 project/vendor/laravel/lumen-framework/src/Console/Kernel.php(117): Laravel\\Lumen\\Console\\Kernel->reportException(Object(Illuminate\\Contracts\\Container\\BindingResolutionException))
#7 project/artisan(43): Laravel\\Lumen\\Console\\Kernel->handle(Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Symfony\\Component\\Console\\Output\\ConsoleOutput))
#8 {main}

因此,我在Github上创建了一个问题:

https://github.com/laravel/lumen-framework/issues/849

1 个答案:

答案 0 :(得分:0)

在Lumen V5.7.6中发布了一个修复程序。

它基本上可以归结为引导过程中被覆盖的路径。

Lumen中的application.php一直在使用命令static:class代替类路径。

已更改为self:class以反映正确的当前路径。

This is the commit that broke it

This is the commit that fixes it

在某些情况下,您可能想覆盖基本应用程序路径,因此在覆盖基本应用程序路径时(例如在引导应用程序时在app.php中)可以添加别名。

例如

$app->alias(overwrite\path\Application::class, \Laravel\Lumen\Application::class);

希望这有助于新提交的人应该修复任何手动覆盖以反映正确的类路径。