A PHP client for elasticsearch.

Fork me on GitHub

Coding Guideliens

Help is very welcomed, but code contributions must be done in respect of PSR-2.

Automatic fixer — PHP-CS-Fixer


php-cs-fixer fix --level=all /path/to/project`

--level=all is used even though it is not part of a standard simply because we like the code to be consistent.

To validate new code added to Elastica run the following command in the top directory. It will show you if your code follows the coding guidelines.

Validator — PHP_CodeSniffer


phpcs --standard=PSR2 lib


  • Since #300, all classes MUST be defined using namespaces.
  • When using classes outside the namespace, you MUST use the use statement.
  • When referencing classes not in a namespace like stdClass or Exception, you MUST NOT use a use statement, simply add a backslash: \stdClass.
  • When class names are used in strings, they MUST be fully qualified, but SHOULD not use a leading backslash. Example: $this->assertInstanceOf('Elastica\Connection', $connection);
  • When documenting, classes MUST be fully qualified with a leading backslash. See #301.