【问题标题】:Laravel 8 error on vendor/lcobucci/jwt/src/Configuration.php供应商/lcobucci/jwt/src/Configuration.php 上的 Laravel 8 错误
【发布时间】:2021-04-19 16:59:10
【问题描述】:

语法错误,意外的 'Parser' (T_STRING),期望函数 (T_FUNCTION) 或 const (T_CONST)", "exception": "ParseError", vendor/lcobucci/jwt/src/Configuration.php", “行”:22

我安装了 PHP 8.0 和 composer v2.0。

该项目在本地使用 xampp 完美运行,但在 Ubuntu 20.04 中显示此错误,Digitalocean 上的 nginx 配置

【问题讨论】:

标签: php jwt laravel-8


【解决方案1】:

我有同样的错误,导致 500 内部服务器错误。

通过将"lcobucci/jwt": "^3.3.3" 添加到我的composer.json 来解决此问题。

主要是依赖问题,首先我在composer.json 中将 laravel/passport 从 10.1 降级到 10.0 以及我的 laravel/framework 从 8.22.1 到 8.21.0,因为它当时工作正常。


vm:~$ php -v
PHP 7.4.13 (cli) (built: Nov 28 2020 06:24:43) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
    with Zend OPcache v7.4.13, Copyright (c), by Zend Technologies

我的composer.json 现在看起来像这样,


"laravel/framework": "^8.14",
"laravel/passport": "^10.1",
"lcobucci/jwt": "^3.3.3",


Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - Conclusion: don't install laravel/passport v10.1.0
    - Installation request for laravel/passport ^10.1 -> satisfiable by laravel/passport[10.x-dev, v10.1.0].
    - Conclusion: remove lcobucci/jwt 3.3.3
    - laravel/passport 10.x-dev requires lcobucci/jwt ^3.4|^4.0 -> satisfiable by lcobucci/jwt[3.4.x-dev, 4.0.x-dev, 4.1.x-dev].
    - Can only install one of: lcobucci/jwt[3.4.x-dev, 3.3.3].
    - Can only install one of: lcobucci/jwt[4.0.x-dev, 3.3.3].
    - Can only install one of: lcobucci/jwt[4.1.x-dev, 3.3.3].
    - Installation request for lcobucci/jwt 3.3.3 -> satisfiable by lcobucci/jwt[3.3.3].

添加


Updating dependencies (including require-dev)
Package operations: 0 installs, 4 updates, 0 removals
  - Updating lcobucci/jwt (3.3.3 => 3.4.2): Loading from cache
  - Updating league/oauth2-server (8.1.1 => 8.2.4): Loading from cache
  - Updating laravel/framework (v8.21.0 => v8.22.1): Loading from cache
  - Updating laravel/passport (v10.0.0 => v10.1.0): Loading from cache

现在一切正常了,你可以找到more details here

【讨论】:

    【解决方案2】:

    我做了composer install --no-plugins,它为我修复了错误。

    【讨论】:

      【解决方案3】:

      我遇到了同样的问题,并通过作曲家更新修复了它。你也可以试试。

      【讨论】:

      • 正如目前所写,您的答案尚不清楚。请edit 添加其他详细信息,以帮助其他人了解这如何解决所提出的问题。你可以找到更多关于如何写好答案的信息in the help center
      猜你喜欢
      • 2021-12-22
      • 2021-10-01
      • 2021-07-18
      • 1970-01-01
      • 1970-01-01
      • 2021-04-10
      • 2017-09-24
      • 2019-04-22
      • 1970-01-01
      相关资源
      最近更新 更多