Home > Back-end >  Undefined type 'Request'.intelephense(1009)
Undefined type 'Request'.intelephense(1009)

Time:12-02

Iam getting this error in Laravel 8 and Name: PHP Intelephense 1.7.1 installed.

<?php

namespace App\Http\Middleware;

use Illuminate\Auth\Middleware\Authenticate as Middleware;
use Request;


class Authenticate extends Middleware
{
    /**
     * Get the path the user should be redirected to when they are not authenticated.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return string|null
     */
    protected function redirectTo($request)
    {
        if (!$request->expectsJson()) {
            if (Request::is('admin/*'))
                return route('admin.login');
            else
                return route('login');
        }
    }
}

and i have tried to add

use Illuminate\Support\Facades\Route;

but still the same any ideas?

Thanks for help ...

CodePudding user response:

Solution 1: You can solve this problem by installing laravel-ide-helper package. Link is here

Solution 2: Put below code to your settings.json

  "intelephense.telemetry.enabled": false,
  "intelephense.completion.triggerParameterHints": true,
  "intelephense.completion.insertUseDeclaration": true,
  "intelephense.trace.server": "messages",
  "intelephense.diagnostics.undefinedClassConstants": false,
  "intelephense.diagnostics.undefinedFunctions": false,
  "intelephense.diagnostics.undefinedConstants": false,
  "intelephense.diagnostics.undefinedProperties": false,
  "intelephense.diagnostics.undefinedTypes": false,
  "intelephense.diagnostics.undefinedMethods": false,

And finally don't forget to restart vscode.

  • Related