您的浏览器过于古老 & 陈旧。为了更好的访问体验, 请 升级你的浏览器
j0785 发布于2023年01月05日 17:57 最近更新于 2023年01月11日 15:43

原创 Hyper框架安装 Blade 视图引擎,执行composer require hyperf/view-engine命令报错

2442 次浏览 读完需要≈ 9 分钟 PHP

内容目录

  • 执行composer require hyperf/view-engine命令报错,报错内容如下:

    Your requirements could not be resolved to an installable set of packages.
    
    Problem 1
    
    - Root composer.json requires hyperf/view-engine ^3.0 -> satisfiable by hyperf/view-engine[v3.0.0-alpha.1, ..., 3.0.x-dev].
    
    - hyperf/view-engine[v3.0.0-alpha.1, ..., 3.0.x-dev] require hyperf/config 3.0.0 -> found hyperf/config[dev-master, v3.0.0-alpha.1, ..., 3.0.x-dev (alias of dev-master)] but it conflicts with your root composer.json require (2.2.0).
    
    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 hyperf/view-engine:*" to figure out if any version is installable, or "composer require hyperf/view-engine:^2.1" if you know which you need.
    
    Installation failed, reverting ./composer.json and ./composer.lock to their original content.

    1672904940832.jpg

  • 报错原因是:安装的视图引擎版本依赖其它安装包
  • 解决方法:

    • 方法一:安装视图引擎需要用到的依赖包hyperf/config 3.0.0(需要注意的是这个安装包要求PHP版本>=8.0,因为示例安装的PHP是7.4.26所以会报错)

      • 执行命令composer require hyperf/config ~3.0.0

        • 如果PHP版本低于8.0则会报如下错误:(解决方案:一 升级PHP,二 降低hyperf/view-engine的版本)

          bash-5.0# composer require hyperf/config ~3.0.0
          ./composer.json has been updated
          Running composer update hyperf/config
          Loading composer repositories with package information
          Updating dependencies
          Your requirements could not be resolved to an installable set of packages.
          
            Problem 1
              - hyperf/config[v3.0.0-alpha.1, ..., 3.0.x-dev] require php >=8.0 -> your php version (7.4.26) does not satisfy that requirement.
              - Root composer.json requires hyperf/config ~3.0.0 -> satisfiable by hyperf/config[v3.0.0-alpha.1, ..., 3.0.x-dev].
          
          Use the option --with-all-dependencies (-W) to allow upgrades, downgrades and removals for packages currently locked to specific versions.
          
          Installation failed, reverting ./composer.json and ./composer.lock to their original content.
      • 然后重新安装composer require hyperf/view-engine
    • 方法二:降低安装的视图引擎版本

      • 执行命令composer require hyperf/view-engine:^2.2
      • 2.2版本号与项目根目录的composer.json文件内requirehyperf/组件的版本号(如下)

            "require": {
                "php": ">=7.3",
                "hyperf/cache": "~2.2.0",
                "hyperf/command": "~2.2.0",
                "hyperf/config": "~2.2.0",
                "hyperf/db-connection": "~2.2.0",
                "hyperf/framework": "~2.2.0",
                "hyperf/guzzle": "~2.2.0",
                "hyperf/http-server": "~2.2.0",
                "hyperf/logger": "~2.2.0",
                "hyperf/memory": "~2.2.0",
                "hyperf/process": "~2.2.0",
                "hyperf/task": "^2.2",
                "hyperf/view": "^2.2"
            }
      • 命令执行结果如下,安装成功

        1672905433689(1).jpg

  • CodePlayer技术交流群1
  • CodePlayer技术交流群2

0 条评论

撰写评论