1

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?

doydoy44
  • 5,720
  • 4
  • 29
  • 45
Michael Thessel
  • 706
  • 5
  • 20

3 Answers3

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).

Ezequiel Muns
  • 7,492
  • 33
  • 57
0

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/"
    }
}
Michael Thessel
  • 706
  • 5
  • 20
  • You could also have put the `autoload` key without modification under the `package` key, which would tie the directive to that project, and you wouldn't have had to bake in the path to the library directory. – Ezequiel Muns May 03 '13 at 00:25
  • That's what I thought too. But I tried this in various variations but it didn't work. I uploded a different config here http://pastebin.com/53PfYM1V. Not sure if you can find any issues. – Michael Thessel May 03 '13 at 01:50
  • That looks exactly the same as my test, but mine worked. I wonder if it's because I did it from scratch (I have noticed that composer gets funny when you edit composer.json without deleting the `vendor/` directory even when running 'update'). – Ezequiel Muns May 03 '13 at 02:06
0

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/"
    }
}
Mohit Padalia
  • 1,549
  • 13
  • 10