Created
August 14, 2014 20:53
-
-
Save Argurth/fce3aeb8a1c2f93abc79 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace User\Service; | |
use Zend\ServiceManager\FactoryInterface; | |
use Zend\ServiceManager\ServiceLocatorInterface; | |
class ElasticaClientFactory implements FactoryInterface | |
{ | |
public function createService(ServiceLocatorInterface $sl) | |
{ | |
$config = $sl->get('Configuration'); | |
$clientOptions = isset($config['elastica']) ? $config['elastica'] : array(); | |
$client = new \Elastica\Client($clientOptions); | |
return $client; | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace User; | |
return array( | |
'controllers' => array( | |
'invokables' => array( | |
'User\Controller\User' => 'User\Controller\UserController', | |
), | |
), | |
'router' => array( | |
'routes' => array( | |
'user' => array( | |
'type' => 'segment', | |
'options' => array( | |
'route' => '/user[/][:action][/:id]', | |
'constraints' => array( | |
'action' => '[a-zA-Z][a-zA-Z0-9_-]*', | |
'id' => '[0-9]+', | |
), | |
'defaults' => array( | |
'controller' => 'User\Controller\User', | |
'action' => 'index', | |
), | |
), | |
), | |
), | |
), | |
'view_manager' => array( | |
'template_path_stack' => array( | |
'user' => __DIR__ . '/../view', | |
), | |
), | |
'doctrine' => array( | |
'driver' => array( | |
__NAMESPACE__ . '_driver' => array( | |
'class' => 'Doctrine\ORM\Mapping\Driver\AnnotationDriver', | |
'cache' => 'array', | |
'paths' => array(__DIR__ . '/../src/' . __NAMESPACE__ . '/Entity') | |
), | |
'orm_default' => array( | |
'drivers' => array( | |
__NAMESPACE__ . '\Entity' => __NAMESPACE__ . '_driver' | |
) | |
) | |
) | |
), | |
'elastica' => array( | |
'servers' => array( | |
array('host' => '127.0.0.1','port' => 9200), | |
// You can add more servers when necessary | |
// array('host' => '127.0.0.1','port' => 9200) | |
), | |
), | |
'service_manager' => array( | |
'factories' => array( | |
'elastica-client' => 'User\Service\ElasticaClientFactory' | |
), | |
) | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment