Install ZendSearch in ZF2 skeleton application

天大地大妈咪最大 提交于 2019-12-08 03:47:02

问题


I'm trying to add Lucene search to my ZF2 project. The package is not listed on the ZF2 packages page. I tried to workaround this by installing it manually from GitHub.

I added this to my composer.json:

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

and installed it via composer.phar:

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

This installed the package but the autoloading doesn't work. Did anyone get ZendSearch working within the ZF2 skeleton application?


回答1:


Have a look at the ZendSearch composer.json. Specifically, the autoload section:

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

You need that in your 'package' to get autoloading working (in fact your package should be as close as possible to the real composer.json).




回答2:


This ended up working for me:

"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/"
    }
}



回答3:


This worked for me

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


来源:https://stackoverflow.com/questions/16290056/install-zendsearch-in-zf2-skeleton-application

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!