Install ZendSearch in ZF2 skeleton application

2019-06-06 01:33发布

问题:

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