Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Illuminate\Contracts\Container\BindingResolutionException : Unresolvable dependency resolving [Parameter #0 [ <required> $methods ]] in class Illuminate\Routing\Route #192

Open
richardyicai opened this issue May 2, 2020 · 3 comments
Assignees

Comments

@richardyicai
Copy link

Hello. When I generated the code I found php artisan route:list complains. Can anyone help on this issue? Thanks.

 Illuminate\Contracts\Container\BindingResolutionException  : Unresolvable dependency resolving [Parameter #0 [ <required> $methods ]] in class Illuminate\Routing\Route

  at /var/www/html/tpgfrontend/vendor/laravel/framework/src/Illuminate/Container/Container.php:994
    990|     protected function unresolvablePrimitive(ReflectionParameter $parameter)
    991|     {
    992|         $message = "Unresolvable dependency resolving [$parameter] in class {$parameter->getDeclaringClass()->getName()}";
    993|
  > 994|         throw new BindingResolutionException($message);
    995|     }
    996|
    997|     /**
    998|      * Register a new resolving callback.

  Exception trace:

  1   Illuminate\Container\Container::unresolvablePrimitive(Object(ReflectionParameter))
      /var/www/html/tpgfrontend/vendor/laravel/framework/src/Illuminate/Container/Container.php:932

  2   Illuminate\Container\Container::resolvePrimitive(Object(ReflectionParameter))
      /var/www/html/tpgfrontend/vendor/laravel/framework/src/Illuminate/Container/Container.php:873

  3   Illuminate\Container\Container::resolveDependencies()
      /var/www/html/tpgfrontend/vendor/laravel/framework/src/Illuminate/Container/Container.php:834

  4   Illuminate\Container\Container::build("Illuminate\Routing\Route")
      /var/www/html/tpgfrontend/vendor/laravel/framework/src/Illuminate/Container/Container.php:681

  5   Illuminate\Container\Container::resolve("Illuminate\Routing\Route", [])
      /var/www/html/tpgfrontend/vendor/laravel/framework/src/Illuminate/Foundation/Application.php:785

  6   Illuminate\Foundation\Application::resolve("Illuminate\Routing\Route", [])
      /var/www/html/tpgfrontend/vendor/laravel/framework/src/Illuminate/Container/Container.php:629

  7   Illuminate\Container\Container::make("Illuminate\Routing\Route", [])
      /var/www/html/tpgfrontend/vendor/laravel/framework/src/Illuminate/Foundation/Application.php:770

  8   Illuminate\Foundation\Application::make("Illuminate\Routing\Route")
      /var/www/html/tpgfrontend/vendor/laravel/framework/src/Illuminate/Container/Container.php:946

  9   Illuminate\Container\Container::resolveClass(Object(ReflectionParameter))
      /var/www/html/tpgfrontend/vendor/laravel/framework/src/Illuminate/Container/Container.php:874

  10  Illuminate\Container\Container::resolveDependencies()
      /var/www/html/tpgfrontend/vendor/laravel/framework/src/Illuminate/Container/Container.php:834

  11  Illuminate\Container\Container::build("Modules\V3\Http\Controllers\TransactionController")
      /var/www/html/tpgfrontend/vendor/laravel/framework/src/Illuminate/Container/Container.php:681

  12  Illuminate\Container\Container::resolve("Modules\V3\Http\Controllers\TransactionController", [])
      /var/www/html/tpgfrontend/vendor/laravel/framework/src/Illuminate/Foundation/Application.php:785

  13  Illuminate\Foundation\Application::resolve("Modules\V3\Http\Controllers\TransactionController", [])
      /var/www/html/tpgfrontend/vendor/laravel/framework/src/Illuminate/Container/Container.php:629

  14  Illuminate\Container\Container::make("Modules\V3\Http\Controllers\TransactionController", [])
      /var/www/html/tpgfrontend/vendor/laravel/framework/src/Illuminate/Foundation/Application.php:770

  15  Illuminate\Foundation\Application::make("Modules\V3\Http\Controllers\TransactionController")
      /var/www/html/tpgfrontend/vendor/laravel/framework/src/Illuminate/Routing/Route.php:233

  16  Illuminate\Routing\Route::getController()
      /var/www/html/tpgfrontend/vendor/laravel/framework/src/Illuminate/Routing/Route.php:833

  17  Illuminate\Routing\Route::controllerMiddleware()
      /var/www/html/tpgfrontend/vendor/laravel/framework/src/Illuminate/Routing/Route.php:794

  18  Illuminate\Routing\Route::gatherMiddleware()
      /var/www/html/tpgfrontend/vendor/laravel/framework/src/Illuminate/Foundation/Console/RouteListCommand.php:173

  19  Illuminate\Foundation\Console\RouteListCommand::getMiddleware(Object(Illuminate\Routing\Route))
      /var/www/html/tpgfrontend/vendor/laravel/framework/src/Illuminate/Foundation/Console/RouteListCommand.php:117

  20  Illuminate\Foundation\Console\RouteListCommand::getRouteInformation(Object(Illuminate\Routing\Route))
      /var/www/html/tpgfrontend/vendor/laravel/framework/src/Illuminate/Foundation/Console/RouteListCommand.php:89

  21  Illuminate\Foundation\Console\RouteListCommand::Illuminate\Foundation\Console\{closure}(Object(Illuminate\Routing\Route))
      [internal]:0

  22  array_map(Object(Closure))
      /var/www/html/tpgfrontend/vendor/laravel/framework/src/Illuminate/Support/Collection.php:638

  23  Illuminate\Support\Collection::map(Object(Closure))
      /var/www/html/tpgfrontend/vendor/laravel/framework/src/Illuminate/Foundation/Console/RouteListCommand.php:90

  24  Illuminate\Foundation\Console\RouteListCommand::getRoutes()
      /var/www/html/tpgfrontend/vendor/laravel/framework/src/Illuminate/Foundation/Console/RouteListCommand.php:74

  25  Illuminate\Foundation\Console\RouteListCommand::handle()
      /var/www/html/tpgfrontend/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:32

  26  call_user_func_array([])
      /var/www/html/tpgfrontend/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:32

  27  Illuminate\Container\BoundMethod::Illuminate\Container\{closure}()
      /var/www/html/tpgfrontend/vendor/laravel/framework/src/Illuminate/Container/Util.php:36

  28  Illuminate\Container\Util::unwrapIfClosure(Object(Closure))
      /var/www/html/tpgfrontend/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:90

  29  Illuminate\Container\BoundMethod::callBoundMethod(Object(Illuminate\Foundation\Application), Object(Closure))
      /var/www/html/tpgfrontend/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:34

  30  Illuminate\Container\BoundMethod::call(Object(Illuminate\Foundation\Application), [])
      /var/www/html/tpgfrontend/vendor/laravel/framework/src/Illuminate/Container/Container.php:590

  31  Illuminate\Container\Container::call()
      /var/www/html/tpgfrontend/vendor/laravel/framework/src/Illuminate/Console/Command.php:134

  32  Illuminate\Console\Command::execute(Object(Symfony\Component\Console\Input\ArgvInput), Object(Illuminate\Console\OutputStyle))
      /var/www/html/tpgfrontend/vendor/symfony/console/Command/Command.php:255

  33  Symfony\Component\Console\Command\Command::run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Illuminate\Console\OutputStyle))
      /var/www/html/tpgfrontend/vendor/laravel/framework/src/Illuminate/Console/Command.php:121

  34  Illuminate\Console\Command::run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
      /var/www/html/tpgfrontend/vendor/symfony/console/Application.php:1001

  35  Symfony\Component\Console\Application::doRunCommand(Object(Illuminate\Foundation\Console\RouteListCommand), Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
      /var/www/html/tpgfrontend/vendor/symfony/console/Application.php:271

  36  Symfony\Component\Console\Application::doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
      /var/www/html/tpgfrontend/vendor/symfony/console/Application.php:147

  37  Symfony\Component\Console\Application::run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
      /var/www/html/tpgfrontend/vendor/laravel/framework/src/Illuminate/Console/Application.php:93

  38  Illuminate\Console\Application::run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
      /var/www/html/tpgfrontend/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php:131

  39  Illuminate\Foundation\Console\Kernel::handle(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
      /var/www/html/tpgfrontend/artisan:37
@richardyicai
Copy link
Author

btw I'm using php 7.4.1 and laravel 6.4

@arthurkushman arthurkushman self-assigned this May 2, 2020
@arthurkushman
Copy link
Contributor

arthurkushman commented May 2, 2020

Hi, thx for reporting - at 1st glance it seems like a Laravel's problem from here:

namespace Illuminate\Routing;
class Route
{
    public function __construct($methods, $uri, $action)
    {
        $this->uri = $uri;
        $this->methods = (array) $methods;
        $this->action = $this->parseAction($action);

        if (in_array('GET', $this->methods) && ! in_array('HEAD', $this->methods)) {
            $this->methods[] = 'HEAD';
        }

        $this->prefix($this->action['prefix'] ?? '');
    }

As it turns out that Reflection can't recognise the actual type of constructors parameter $method in this case and it is normal because there is no type-hint. But we can't provide a type as it can be an array as well as string.
I will investigate this problem further if U find the solution faster, please let me know.
PHP 7.4.3/Laravel 7.0.8

@Parables
Copy link

Facing the same issue, any solutions for this?

P.s: I still don't understand why you would abandon this package cause honestly, as far as json:api is concerned, I find no better alternatives out there. Laravel-JSON-API might be a worthy competitor but hell no would I write documentation manually when it can be generated

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants