简体   繁体   English

我在实时服务器上使用 Laravel 登录 API 时出错

[英]I am getting error using Laravel login API on Live server

I am getting an error using laravel api, the error only appears when I have uploaded my project on live server, but it is working on live server我在使用 laravel api 时遇到错误,该错误仅在我将项目上传到实时服务器时出现,但它正在实时服务器上运行

syntax error, unexpected 'Parser' (T_STRING), expecting function (T_FUNCTION) or const (T_CONST)

Controller for API: Controller 用于 API:

<?php

namespace App\Http\Controllers\API;

use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use App\User; 
// use Illuminate\Support\Facades\Auth; 
use Validator;
use Auth;

    class UserController extends Controller
    {
        public $successStatus = 200;
        /** 
         * login api 
         * 
         * @return \Illuminate\Http\Response 
         */ 
        public function login(){ 
            if(Auth::attempt(['email' => request('email'), 'password' => request('password')])){ 
                $user = Auth::user(); 
                $success['token'] =  $user->createToken('MyApp')-> accessToken; 
                return response()->json(['success' => $success], $this-> successStatus); 
            } 
            else{ 
                return response()->json(['error'=>'Unauthorised'], 401); 
            } 
        }
    }

The error is in this file,错误在这个文件中,

ParseError: syntax error, unexpected 'Parser' (T_STRING), expecting function (T_FUNCTION) or const (T_CONST) in file /home/.../.../.../project/vendor/lcobucci/jwt/src/Configuration.php on line 22

在此处输入图像描述

I have solved the issue by updating php version from 7.3 to 7.4, although in package.json the require version is 7.2.5我已经通过将 php 版本从 7.3 更新到 7.4 解决了这个问题,尽管在 package.json 中需要的版本是 7.2.5

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

相关问题 为什么我在Laravel中收到“未定义[Route [/ login]的错误]”? - Why am i getting “Route [/login] not defined error” in Laravel? Laravel API在实时服务器上收到404错误 - Laravel API receiving 404 error on live server 将我的 Laravel 项目上传到服务器后出现错误 - I am getting error after uploading my Laravel project to server 为什么在Laravel Framework中出现此内部服务器错误? - Why am I getting this Internal Server Error in the Laravel Framework? 我正在尝试更新数据,但使用 laravel 时出错 - I am trying to update data but getting error using laravel 为什么在 laravel 中使用 Sass 和 AgGrid 时出现错误? - Why am I getting an error when using Sass with AgGrid in laravel? 当我通过 API 从 Laravel 的数据库中获取用户数据时出现错误 - i am getting error when i am fetching user data from database in laravel through API 使用Ajax进行实时搜索并在Laravel 5.8上遇到错误“ 500(内部服务器错误)” - Live Search using Ajax and Getting Error “500 (Internal Server Error)” on Laravel 5.8 我正在尝试在laravel中创建多个表用户和管理员登录,但出现错误 - I am trying to create multiple table user and admin login in laravel, getting error 使用 laravel socialite 实现 facebook 登录时出现 parse_str() 错误 - I am getting parse_str() error while implementing facebook login with laravel socialite
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM