在ZF2骨架应用程序中安装ZendSearch

时间:2013-04-29 23:48:11

标签: php zend-framework2 zend-search-lucene

我正在尝试将Lucene搜索添加到我的ZF2项目中。该软件包未列在ZF2 packages page上。我试图通过从GitHub手动安装来解决此问题。

我把它添加到我的composer.json:

"repositories": [{
    "type": "package",
    "package": {
        "name": "zendframework/zendsearch",
        "version": "0.1",
        "source": {
            "url": "https://github.com/zendframework/ZendSearch.git",
            "type": "git",
            "reference": "master"
        }
    }
}]

并通过composer.phar安装它:

$ ./composer.phar require zendframework/zendsearch:0.1

这安装了软件包,但自动加载不起作用。有没有人在ZF2骨架应用程序中使用ZendSearch?

3 个答案:

答案 0 :(得分:1)

查看ZendSearch composer.json。具体来说,autoload部分:

"autoload": {
    "psr-0": {
        "ZendSearch": "library/"
    }
}

你需要在你的'包'中使自动加载工作(实际上你的包应该尽可能接近真正的composer.json)。

答案 1 :(得分:0)

这最终为我工作:

"repositories": [
    {
        "type": "composer",
        "url": "https://packages.zendframework.com/"
    },
    {
        "type": "package",
        "package": {
            "name": "zendframework/zendsearch",
            "version": "0.1",
            "source": {
                "url": "https://github.com/zendframework/ZendSearch.git",
                "type": "git",
                "reference": "master"
            }
        }
    }
],
"autoload": {
    "psr-0": {
        "ZendSearch\\": "vendor/zendframework/zendsearch/library/"
    }
}

答案 2 :(得分:0)

这对我有用

"require": {
    "php": ">=5.3.3",
    "zendframework/zendframework": "2.3.*",
    "zendframework/zendsearch": "dev-master"
},
"autoload": {
    "psr-0": {
        "ZendSearch\\": "vendor/zendframework/zendsearch/library/"
    }
}