Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Elastica Bundle Laravel Package

bok/elastica-bundle

View on GitHub
Deep Wiki
Context7

Using a Serializer in FOSElasticaBundle

FOSElasticaBundle supports using a Serializer component to serialize your objects to JSON which will be sent directly to the Elasticsearch server. Combined with automatic mapping it means types do not have to be mapped.

A) Install and declare the serializer

Both the Symfony Serializer and JMSSerializerBundle are supported.

Enable the Symfony serializer in the configuration:

#app/config/config.yml
fos_elastica:
    serializer: ~

Alternatively the JMS serializer can be used as follows:

#app/config/config.yml
fos_elastica:
    serializer:
        serializer: jms_serializer

B) Set up each defined index to support serialization

An index does not need to have mappings defined when using a serializer. An example configuration for an index in this case:

fos_elastica:
    indexes:
        user:
            serializer:
                groups: [elastica]

And inside the User class:

use Symfony\Component\Serializer\Annotation\Groups;

class User {

    /**
     * [@Groups](https://github.com/Groups)({"elastica"})
     *
     * [@var](https://github.com/var) string
     */
    private $username;
    
}

In addition the JMS Serializer allows you to specify options for version and whether to serialize null

fos_elastica:
    indexes:
        user:
            serializer:
                groups: [elastica]
                version: '1.1'
                serialize_null: true
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
graham-campbell/flysystem
capell-app/block-library
axium/identity
cetria/laravel-dummy-models
cetria/reflection-helper
agropredict/sso-auth-bundle
evolvestudio/spam-protection
directorytree/opensearch-client
directorytree/opensearch-adapter
datacore/hub-sdk
develia/commons
cuci/prototurk-sdk
cuci/prototurk-sdk-symfony
develia/geo-bundle
dreamzy/livewire-charts
touchestate-sdk/php-sdk
22h/doctrine-garbage-collection-bundle
agtp/agtp-php
agtp/mod-php
splash/sonata-admin