IMPORTANT: No additional bug fixes or documentation updates
will be released for this version. For the latest information, see the
current release documentation.
Implementing your own Serializer
editImplementing your own Serializer
editIf you want to use your own custom serializer, you need to implement the
SerializerInterface
interface:
class MyCustomSerializer implements SerializerInterface { /** * Serialize request body * * @param string|array $data Request body * * @return string */ public function serialize($data) { // code here } /** * Deserialize response body * * @param string $data Response body * @param array $headers Response Headers * * @return array|string */ public function deserialize($data, $headers) { // code here } }
To use it, you simply provide the class path in the configuration parameters:
$params['serializerClass'] = '\MyProject\Serializers\MyCustomSerializer'; $client = new Elasticsearch\Client($params);