Search code examples
phplaravelphpstorm

PhpStorm Code Inspector: "Method not found" in Route File of Laravel 5.3


The Code Inspector of my PhpStorm 2016.1.2 (with Laravel Plugin installed) says about the following code.

Code routes/api.php

<?php

$this->app['router']->group(
    ['namespace' => 'Foo\Access\Controllers'],
    function() {
        $this->app['router']->post('auth/login', ['uses' => 'AuthController@login']);
    }
);

Errors

  • Method 'group' not found in (at line 3)
  • Method 'post' not found in (at line 6)

Question

How can I tell PhpStorm that $this-app['router'] references to Illuminate\Routing\Router?


Solution

  • The solution was very simple. I changed the array access of the object.

    <?php
    
        $this->app->router->group(
        ['namespace' => 'Foo\Access\Controllers'],
        function() {
            $this->app->router->post('auth/login', ['uses' => 'AuthController@login']);
        }
    );