Skip to content

Instantly share code, notes, and snippets.

@Argurth
Created August 14, 2014 20:53
Show Gist options
  • Save Argurth/fce3aeb8a1c2f93abc79 to your computer and use it in GitHub Desktop.
Save Argurth/fce3aeb8a1c2f93abc79 to your computer and use it in GitHub Desktop.
<?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;
}
}
<?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