Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Undefined type 'Request'.intelephense(1009)

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 ...

like image 888
Salem Avatar asked Jul 13 '26 02:07

Salem


2 Answers

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.

like image 87
Biswajit Biswas Avatar answered Jul 15 '26 16:07

Biswajit Biswas


"Laravel Snippets" - VScode install the plugin.

Maybe it will be useful to someone.

like image 45
Mitivil Avatar answered Jul 15 '26 17:07

Mitivil