如何在Yii2中实现Hook?

时间:2017-11-07 05:43:06

标签: php json git yii2 hook

我已在本地计算机上成功设置了Yii2。我目前的Yii版本是2.0.11.2。我想在我的项目中使用hook。这里我运行了composer命令来安装hook。但无法安装它。

composer require --prefer-dist yiike/yii2-hook "*"

错误:

C:\xampp\htdocs\yii2>composer require --prefer-dist yiike/yii2-hook "*"
./composer.json has been updated
The "extra.asset-installer-paths" option is deprecated, use the "config.fxp-asse
t.installer-paths" option
Loading composer repositories with package information
Updating dependencies (including require-dev)

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

  Problem 1
    - The requested package yiike/yii2-hook * is satisfiable by yiike/yii2-hook[
dev-master] but these conflict with your requirements or minimum-stability.


Installation failed, reverting ./composer.json to its original content.

C:\xampp\htdocs\yii2>

我正在关注此文档:https://packagist.org/packages/yiike/yii2-hook(显然未在文档中提及)

或者我在我的composer.json中添加了"yiike/yii2-hook": "*"然后更新作曲家。但同样的错误即将来临。

你能帮我吗

修改

{
    "name": "yiisoft/yii2-app-basic",
    "description": "Yii 2 Basic Project Template",
    "keywords": ["yii2", "framework", "basic", "project template"],
    "homepage": "http://www.yiiframework.com/",
    "type": "project",
    "license": "BSD-3-Clause",
    "support": {
        "issues": "https://github.com/yiisoft/yii2/issues?state=open",
        "forum": "http://www.yiiframework.com/forum/",
        "wiki": "http://www.yiiframework.com/wiki/",
        "irc": "irc://irc.freenode.net/yii",
        "source": "https://github.com/yiisoft/yii2"
    },
    "minimum-stability": "stable",
    "require": {
        "php": ">=5.4.0",
        "yiisoft/yii2": "~2.0.5",
        "yiisoft/yii2-bootstrap": "~2.0.0",
        "yiisoft/yii2-swiftmailer": "~2.0.0",
        "yiike/yii2-hook": "*"
    },
    "require-dev": {
        "yiisoft/yii2-debug": "~2.0.0",
        "yiisoft/yii2-gii": "~2.0.0",
        "yiisoft/yii2-faker": "~2.0.0",

        "codeception/base": "^2.2.3",
        "codeception/verify": "~0.3.1",
        "codeception/specify": "~0.4.3"
    },
    "config": {
        "process-timeout": 1800
    },
    "scripts": {
        "post-create-project-cmd": [
            "yii\\composer\\Installer::postCreateProject"
        ]
    },
    "extra": {
        "yii\\composer\\Installer::postCreateProject": {
            "setPermission": [
                {
                    "runtime": "0777",
                    "web/assets": "0777",
                    "yii": "0755"
                }
            ],
            "generateCookieValidationKey": [
                "config/web.php"
            ]
        },
        "asset-installer-paths": {
            "npm-asset-library": "vendor/npm",
            "bower-asset-library": "vendor/bower"
        }
    }
}

2 个答案:

答案 0 :(得分:0)

您尝试安装的库似乎没有任何可用的稳定版本,并且composer.json已配置为在稳定版本的软件包上接受

minimum-stability更改为dev,问题应该得到解决

答案 1 :(得分:0)

你应该使用稳定版本的钩子或改变你的 作曲家设置minimum-stabilitydev

或者你可以使用这个jquery hook Jquery Hook