You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Laravel 10安装Laravel Passport失败,求分步解决方案

Windows 10 XAMPP(PHP8.2.0)安装Laravel Passport错误分步解决方法

核心错误汇总

  1. 无法解析repo.packagist.org域名(curl error 6)
  2. 依赖版本冲突(psr/http-message、illuminate/auth、guzzlehttp/guzzle版本不兼容)
  3. PHP sodium扩展缺失

分步解决方法

一、处理域名解析失败问题

  • 验证外网访问:在浏览器打开https://repo.packagist.org/packages.json,确认能正常加载内容
  • 切换国内Composer镜像:执行以下命令替换官方镜像
    composer config -g repo.packagist composer https://mirrors.aliyun.com/composer/
    
  • 清除Composer缓存:
    composer clear-cache
    

二、解决依赖版本冲突问题

依赖冲突源于现有项目依赖与Passport所需依赖不兼容,可通过以下方式处理:

  • 使用-W参数允许全局依赖调整:该参数会让Composer自动升级、降级或移除冲突依赖,执行命令:
    composer require laravel/passport -W
    
  • 指定兼容的Passport版本:根据Laravel版本匹配(Laravel 10对应Passport 11.x),执行:
    composer require laravel/passport:^11.0 -W
    
  • 手动修复psr/http-message冲突:若上述命令失败,修改项目根目录composer.json,将psr/http-message的版本约束改为^1.0|^2.0,再执行:
    composer update psr/http-message
    composer require laravel/passport
    

三、解决PHP sodium扩展缺失问题

  • 开启XAMPP中的sodium扩展:
    1. 打开XAMPP控制面板,点击PHP模块右侧的「Config」,选择php.ini
    2. 找到;extension=sodium,删除前面的分号;,改为extension=sodium
    3. 保存文件,重启XAMPP的Apache服务
  • 验证扩展状态:打开终端执行php -m,检查输出列表中是否包含sodium
  • 临时绕过(不推荐):若暂时无法开启扩展,可执行以下命令强制安装,但可能导致Passport部分功能异常:
    composer require laravel/passport --ignore-platform-req=ext-sodium
    

错误详情参考

composer require laravel/passport
https://repo.packagist.org could not be fully loaded (curl error 6 while downloading https://repo.packagist.org/packages.json: Could not resolve host: repo.packagist.org), package information was loaded from the local cache and may be out of date
./composer.json has been updated
Running composer update laravel/passport
Loading composer repositories with package information
https://repo.packagist.org could not be fully loaded (curl error 6 while downloading https://repo.packagist.org/packages.json: Could not resolve host: repo.packagist.org), package information was loaded from the local cache and may be out of date
Updating dependencies
Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - laravel/passport[v11.5.0, ..., v11.8.4] require league/oauth2-server ^8.2 -> satisfiable by league/oauth2-server[8.2.0, ..., 8.5.3].
    - laravel/passport[v11.8.5, ..., v11.8.8] require lcobucci/jwt ^4.3|^5.0 -> satisfiable by lcobucci/jwt[4.3.0, 5.0.0].
    - league/oauth2-server[8.5.2, ..., 8.5.3] require lcobucci/jwt ^4.3 || ^5.0 -> satisfiable by lcobucci/jwt[4.3.0, 5.0.0].
    - laravel/passport[v0.1.0, ..., v0.2.4, v1.0.0, ..., v1.0.18, v2.0.0, ..., v2.0.11, v3.0.0, ..., v3.0.2, v4.0.0, ..., v4.0.3, v5.0.0, ..., v5.0.3, v6.0.0, ..., v6.0.7, v7.0.0, ..., v7.5.1] require guzzlehttp/guzzle ~6.0 -> found guzzlehttp/guzzle[6.0.0, ..., 6.5.8] but it conflicts with your root composer.json require (^7.2).
    - laravel/passport[v8.0.0, ..., v8.5.0, v9.0.0, ..., v9.3.2] require php ^7.2 -> your php version (8.2.0) does not satisfy that requirement.
    - laravel/passport v9.4.0 requires illuminate/auth ^6.18.31|^7.22.4 -> found illuminate/auth[v6.18.31, ..., v6.20.44, v7.22.4, ..., v7.30.6] but these were not loaded, likely because it conflicts with another require.
    - laravel/passport[v10.0.0, ..., v10.0.1] require php ^7.3 -> your php version (8.2.0) does not satisfy that requirement.
    - laravel/passport[v10.1.0, ..., v10.2.2] require illuminate/auth ^8.2 -> found illuminate/auth[v8.2.0, ..., v8.83.27] but these were not loaded, likely because it conflicts with another require.
    - laravel/passport[v10.3.0, ..., v10.3.2] require illuminate/auth ^8.2|^9.0 -> found illuminate/auth[v8.2.0, ..., v8.83.27, v9.0.0, ..., v9.52.15] but these were not loaded, likely because it conflicts with another require.
    - laravel/passport[v10.3.3, ..., v10.4.2] require illuminate/auth ^8.37|^9.0 -> found illuminate/auth[v8.37.0, ..., v8.83.27, v9.0.0, ..., v9.52.15] but these were not loaded, likely because it conflicts with another require.
    - laravel/passport[v11.0.0, ..., v11.4.0] require illuminate/auth ^9.0 -> found illuminate/auth[v9.0.0, ..., v9.52.15] but these were not loaded, likely because it conflicts with another require.
    - league/oauth2-server[8.2.0, ..., 8.5.1] require psr/http-message ^1.0.1 -> found psr/http-message[1.0.1, 1.1] but the package is fixed to 2.0 (lock file version) by a partial update and that version does not match. Make sure you list it as an argument for the update command.
    - lcobucci/jwt[4.3.0, 5.0.0] require ext-sodium * -> it is missing from your system. Install or enable PHP's sodium extension.
    - Root composer.json requires laravel/passport * -> satisfiable by laravel/passport[v0.1.0, ..., v0.2.4, v1.0.0, ..., v1.0.18, v2.0.0, ..., v2.0.11, v3.0.0, v3.0.1, v3.0.2, v4.0.0, v4.0.1, v4.0.2, v4.0.3, v5.0.0, v5.0.1, v5.0.2, v5.0.3, v6.0.0, ..., v6.0.7, v7.0.0, ..., v7.5.1, v8.0.0, ..., v8.5.0, v9.0.0, ..., v9.4.0, v10.0.0, ..., v10.4.2, v11.0.0, ..., v11.8.8].

To enable extensions, verify that they are enabled in your .ini files:
    - F:\xampp\php\php.ini
You can also run `php --ini` in a terminal to see which files are used by PHP in CLI mode.
Alternatively, you can run Composer with `--ignore-platform-req=ext-sodium` to temporarily ignore these required extensions.

Use the option --with-all-dependencies (-W) to allow upgrades, downgrades and removals for packages currently locked to specific versions.
You can also try re-running composer require with an explicit version constraint, e.g. "composer require laravel/passport:*" to figure out if any version is installable, or "composer require laravel/passport:^2.1" if you know which you need.

Installation failed, reverting ./composer.json and ./composer.lock to their original content.

内容的提问来源于stack exchange,提问作者RASOOL FALLAH

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.13 21:35:58