Elastica with Zend Framework 2?

611 views
Skip to first unread message

victor

unread,
Jan 8, 2013, 10:49:59 AM1/8/13
to elastica-...@googlegroups.com
Is posible to use Elastica lib with Zend framework 2? 

If it is posible,  I would appreciate some example because i'm trying to do with no result.


victor

unread,
Jan 9, 2013, 7:39:32 AM1/9/13
to elastica-...@googlegroups.com
Respose to myselft:

Yes, it's possible. 

I added it like a new module (with module.php and the other things). To load classes, first generate the autoload_classmap.php with the automatic generator included with zf2 (i have attached my file). Second, in module.php use Zend\Loader\ClassMapAutoloader with this file to map classes. In controller (in my case) imports the namespaces and ready to work. (do not forget to add module to application.config.php)
autoload_classmap.php

ruflin

unread,
Jan 9, 2013, 8:05:58 AM1/9/13
to elastica-...@googlegroups.com
Hi victor

Thx for answering it yourself. It is actually even simpler if you use composer with packagist to add it to ZF 2


Nicolas

Sudhir Shrestha

unread,
May 28, 2013, 6:25:33 AM5/28/13
to elastica-...@googlegroups.com
Install Elastica using composer
  1. update composer.json to
    "repositories":[
            {
                "type": "package",
                "package": {
                    "name": "ruflin/Elastica",
                    "version": "0.19.8.0",
                    "source": {
                        "url": "https://github.com/ruflin/Elastica.git",
                        "type": "git",
                        "reference": "master"
                    }
                }
            }
    ],
        "autoload": {
            "psr-0":{
                "Elastica": "vendor/ruflin/Elastica/lib/"
            }
        },
  2. run via cli:  php composer.phar update to install
  3. now you can access the Elastica class files from controllers

Sudhir Shrestha

unread,
May 28, 2013, 6:28:50 AM5/28/13
to elastica-...@googlegroups.com
and offcourse add

"require":{
 "ruflin/Elastica":"0.19.8.0",
 .....

}

On Tuesday, January 8, 2013 9:34:59 PM UTC+5:45, victor wrote:
Reply all
Reply to author
Forward
0 new messages