laravel-permission 安装报错

1. 运行环境

WNMP

1). 当前使用的 Laravel 版本?

Laravel Framework 6.20.44

2).PHP 版本:

7.2.9

3). 当前系统

Windows 10

2. 问题描述?

我在项目中运行composer安装laravel-permission报错,无论是直接安装还是写人到composer.json中再执行更新都会报错

composer require "spatie/laravel-permission:~2.7"

这是我的composer.json

{
    "name": "laravel/laravel",
    "type": "project",
    "description": "The Laravel Framework.",
    "keywords": [
        "framework",
        "laravel"
    ],
    "license": "MIT",
    "require": {
        "php": "^7.2.5|^8.0",
        "barryvdh/laravel-snappy": "^0.4.8",
        "elasticsearch/elasticsearch": "~6.0",
        "fideloper/proxy": "^4.4",
        "gregwar/captcha": "^1.1",
        "guzzlehttp/guzzle": "^7.3",
        "jacobcyl/ali-oss-storage": "^2.1",
        "james-heinrich/getid3": "^1.9",
        "jiguang/jmessage": "^1.1",
        "jiguang/jsms": "~1.0",
        "johnlui/aliyun-oss": "^2.2",
        "jpush/jpush": "^3.6.6",
        "laravel/framework": "^6.20",
        "laravel/horizon": "~3.0",
        "laravel/tinker": "^2.5",
        "maatwebsite/excel": "^3.1",
        "moontoast/math": "^1.2",
        "overtrue/easy-sms": "^1.3",
        "overtrue/laravel-lang": "~3.0",
        "overtrue/laravel-wechat": "^5.1",
        "predis/predis": "^1.1",
        "tecnickcom/tcpdf": "^6.4",
        "yansongda/pay": "^2.9"
    },
    "require-dev": {
        "facade/ignition": "^1.16.4",
        "fakerphp/faker": "^1.9.1",
        "laravel/ui": "^1.0",
        "mockery/mockery": "^1.0",
        "nunomaduro/collision": "^3.0",
        "phpunit/phpunit": "^8.5.8|^9.3.3"
    },
    "config": {
        "preferred-install": "dist",
        "sort-packages": true,
        "optimize-autoloader": true,
        "platform": {
            "ext-pcntl": "7.2",
            "ext-posix": "7.2"
        }
    },
    "extra": {
        "laravel": {
            "dont-discover": []
        }
    },
    "autoload": {
        "psr-4": {
            "App\\": "app/"
        },
        "classmap": [
            "database/seeds",
            "database/factories"
        ],
        "files": [
            "app/helpers.php"
        ]
    },
    "autoload-dev": {
        "psr-4": {
            "Tests\\": "tests/"
        }
    },
    "minimum-stability": "dev",
    "prefer-stable": true,
    "scripts": {
        "post-autoload-dump": [
            "Illuminate\\Foundation\\ComposerScripts::postAutoloadDump",
            "@php artisan package:discover --ansi"
        ],
        "post-root-package-install": [
            "@php -r \"file_exists('.env') || copy('.env.example', '.env');\""
        ],
        "post-create-project-cmd": [
            "@php artisan key:generate --ansi"
        ]
    }
}

4. 您实际得到的结果?

laravel-permission 安装报错
Problem 1
- spatie/laravel-permission[2.33.0, …, v2.x-dev] require illuminate/auth 5.3.0|5.4.0|5.5.0|5.6.0|5.7.0|5.8.0 -> found illuminate/auth[v5.3.0, …, 5.8.x-dev] but these were not loaded, likely because it conflicts with another require.
- spatie/laravel-permission[2.7.0, …, 2.8.2] require illuminate/auth 5.3.0|5.4.0|5.5.0 -> found illuminate/auth[v5.3.0, …, 5.5.x-dev] but these were not loaded, likely because it conflicts with another require.
- spatie/laravel-permission[2.9.0, …, 2.16.0] require illuminate/auth ~5.3.0|
5.4.0|5.5.0|5.6.0 -> found illuminate/auth[v5.3.0, …, 5.6.x-dev] but these were not loaded, likely because it conflicts with another require.
- spatie/laravel-permission[2.17.0, …, 2.32.0] require illuminate/auth 5.3.0|5.4.0|5.5.0|5.6.0|5.7.0 -> found illuminate/auth[v5.3.0, …, 5.7.x-dev] but these were not loaded, likely because it conflicts with another require.
- spatie/laravel-permission[2.17.1, …, 2.20.0] require laravel/framework ~5.4.0|
5.5.0|5.6.0|5.7.0 -> found laravel/framework[v5.4.0, …, 5.7.x-dev] but it conflicts with your root composer.json require (^6.20).
- Root composer.json requires spatie/laravel-permission ~2.7 -> satisfiable by spatie/laravel-permission[2.7.0, …, v2.x-dev].

Use the option –with-all-dependencies (-W) to allow upgrades, downgrades and removals for packages currently locked to specific versions.

《L02 从零构建论坛系统》
以构建论坛项目 LaraBBS 为线索,展开对 Laravel 框架的全面学习。应用程序架构思路贴近 Laravel 框架的设计哲学。
《G01 Go 实战入门》
从零开始带你一步步开发一个 Go 博客项目,让你在最短的时间内学会使用 Go 进行编码。项目结构很大程度上参考了 Laravel。
最佳答案

illuminate/auth 对于permission 依赖的版本和目前系统安装的版本不匹配,造成的,安装时候去掉指定版本 ^2.7 ,自己去匹配版本

3年前 评论
讨论数量: 1

illuminate/auth 对于permission 依赖的版本和目前系统安装的版本不匹配,造成的,安装时候去掉指定版本 ^2.7 ,自己去匹配版本

3年前 评论

讨论应以学习和精进为目的。请勿发布不友善或者负能量的内容,与人为善,比聪明更重要!