简体   繁体   English

Passport中不存在Lcobucci \\\\ JWT \\\\ Parser类(Laravel 5.6)

[英]Class Lcobucci\\JWT\\Parser does not exist in Passport (Laravel 5.6)

I am using Passport for API authentication. 我正在使用Passport进行API身份验证。 Here are the packages that are installed in my composer.json file. 这是我的composer.json文件中安装的软件包。

"require": {
        "php": "^7.1.3",
        "barryvdh/laravel-dompdf": "*",
        "baum/baum": "~1.1",
        "benwilkins/laravel-fcm-notification": "^2.0",
        "fideloper/proxy": "^4.0",
        "intervention/image": "^2.4",
        "ixudra/curl": "^6.16",
        "laravel/framework": "5.6.*",
        "laravel/passport": "^6.0",
        "laravel/tinker": "^1.0",
        "lcobucci/jwt": "^3.2",
        "league/flysystem-aws-s3-v3": "^1.0",
        "pbmedia/laravel-ffmpeg": "^2.1",
        "predis/predis": "^1.1",
        "tymon/jwt-auth": "^1.0@dev",
        "zizaco/entrust": "^1.9"
    },

I don't have any complicated packages as such. 我没有任何复杂的包装。 Just trying to do simple things here to login and get details of users. 只是尝试在此处做一些简单的事情来登录并获取用户的详细信息。

I have tried installing and uninstalling the Passport package multiple times. 我已尝试多次安装和卸载Passport软件包。

Note: The code seems to be working fine on localhost but creating issue when running on production server environment. 注意:该代码在localhost上似乎工作正常,但是在生产服务器环境中运行时会产生问题。 Its a very strange issue I am getting for the first time. 这是我第一次遇到一个非常奇怪的问题。

I am not able to get the issue. 我无法解决问题。 I am getting this issue on 我正在解决这个问题

 public function login(Request $request){

    if(Auth::guard('customer')->attempt(['email' => request('email'), 'password' => request('password')])){
     $user = Auth::guard('customer')->user();
         $select=$this->devicecustomers->where('customer_id',$user->id)->where('deviceid',$request['deviceid'])->count();

      if($select>0)
          {
          $expire_date = \Carbon::now()->addDays(365);
          $tokan = $user->createToken($user->id);   ====>>>  // // //This is the line were I am getting error. 
          $tokensubproperty = $tokan->token;
          $tokensubproperty->expires_at = $expire_date;
          $success['token'] =  $tokan->accessToken;
          $success['expires_at'] = $expire_date;

        $device = $this->devicecustomers->where('customer_id',$user->id)->where('deviceid',$request['deviceid'])->update(['mobile_tokan'=>$request->mobile_tokan, 'login_status'=>"login"]);
        return response()->json(['status' => 'success','success' => $success], $this->successStatus);
      }


         }
         else{

            return response()->json(['status' => 'error','error'=>'Invalid email or password.']);
         }

    }

This line is the error $tokan = $user->createToken($user->id); 这行是错误$tokan = $user->createToken($user->id);

Did someone else faced the same problem before? 以前有人遇到过同样的问题吗? Can someone suggest what is the issue? 有人可以建议出什么问题吗?

After debugging the code I find the issue on this function app/vendor/laravel/passport/src/HasApiTokens.php 调试代码后,我在此功能app / vendor / laravel / passport / src / HasApiTokens.php上发现了问题

 public function createToken($name, array $scopes = [])
    {
        return Container::getInstance()->make(PersonalAccessTokenFactory::class)->make(
            $this->getKey(), $name, $scopes
        );
    }

I may be a little late to the party. 我参加聚会可能有点晚了。

Did you run composer update on prod? 您是否在产品上运行作曲家更新?

Did you make sure to run the migrations on prod? 您确定要在产品上运行迁移吗?

Did you use php artisan to install passport on prod? 您是否使用php artisan在产品上安装通行证?

Look in the storage/ directory, are your public/private keys in there? 在storage /目录中查找,您的公钥/私钥在其中吗?

PS Go F off @Samuel Liew. PS去@塞缪尔·刘。 Go be a mod in places that really need it. 在真正需要它的地方成为mod。 Whether you believe it or not, your time is precious. 无论您信不信,您的时间都是宝贵的。 You are wasting it here. 您在这里浪费它。 Bad mod, bad. 坏mod,坏。 I figure you wouldn't know what you're talking about because you probably aren't that familiar with Laravel. 我想您不会知道您在说什么,因为您可能不太熟悉Laravel。 It is an answer. 这是一个答案。 These are the literal steps to ensure your Laravel prod matches local when adding new packages, you douchebag. 这些是确保您的Laravel产品在添加新程序包时的本地步骤的字面步骤。 I even tweaked the steps to verify all the parts are there for this specific package to work. 我什至调整了步骤以验证所有零件是否都在工作,以便该特定的程序包能够正常工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Laravel:目标 [Lcobucci\JWT\Parser] 不可实例化 - Laravel: Target [Lcobucci\JWT\Parser] is not instantiable Laravel 护照:Lcobucci\JWT\Token\InvalidTokenStructure 值不是允许的日期格式 - Laravel passport: Lcobucci\JWT\Token\InvalidTokenStructure Value is not in the allowed date format 不推荐将声明复制为标头,并将从 v4.0 中删除 - Laravel lcobucci/jwt package 中的护照问题 - Replicating claims as headers is deprecated and will removed from v4.0 - Laravel Passport Problem in lcobucci/jwt package Laravel-类filter.parser不存在 - Laravel - Class filter.parser does not exist Laravel 5.6:未捕获的反射异常:类 env 不存在 - Laravel 5.6: Uncaught ReflectionException: Class env does not exist 未捕获的 ReflectionException:升级到 Laravel 5.6 后类 env 不存在 - Uncaught ReflectionException: Class env does not exist after upgrade to Laravel 5.6 Laravel 5.6类App \\ Http \\ Controllers \\ PostController不存在 - Laravel 5.6 Class App\Http\Controllers\PostController does not exist Controller 不存在于 laravel 5.6 - Controller does not exist in laravel 5.6 JWT,Laravel类Tymon \\ JWTAuth \\ MiddlewareGetUserFromToken不存在 - JWT, Laravel Class Tymon\JWTAuth\MiddlewareGetUserFromToken does not exist Laravel 8 供应商/lcobucci/jwt/src/Configuration.php 错误 - Laravel 8 error on vendor/lcobucci/jwt/src/Configuration.php
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM