2017 © Pedro Peláez
 

library eav-model-bundle

Symfony3 & Doctrine implementation of a Entity-Attribute-Value model, easily extendable

image

sidus/eav-model-bundle

Symfony3 & Doctrine implementation of a Entity-Attribute-Value model, easily extendable

  • Thursday, July 26, 2018
  • by VincentChalnot
  • Repository
  • 5 Watchers
  • 31 Stars
  • 4,699 Installations
  • PHP
  • 7 Dependents
  • 0 Suggesters
  • 23 Forks
  • 2 Open issues
  • 33 Versions
  • 13 % Grown

The README.md

Sidus/EAVModelBundle Documentation

SensioLabsInsight, (*1)

The canonical version of this documentation can be found here: https://vincentchalnot.github.io/SidusEAVModelBundle, (*2)

Introduction

This bundle allows you to quickly set up a dynamic model in a Symfony project using Doctrine.
Model configuration is done in Yaml and everything can be easily extended., (*3)

The main feature of this model that exists nowhere else to my knowledge is the possibility to contextualize data based on as many contextualization axis you need., (*4)

All EAV model allows you to contextualize data based on the language or the country (yes: internationalization is a subset of data contextualization), some models allows you to contextualize your data based on some channels or scopes but this particular implementation allows you to manage contextualization axis to conform with your business logic, not the other way around., (*5)

Main Features:, (*6)

Documentation index

Other documentation entries

Looking for something ?

Check the Q&A section and don't hesitate to ask questions in the issues., (*7)

What’s an EAV model

EAV stands for Entity-Attribute-Value, (*8)

The main feature consists in storing values in a different table than the entities. Check the confusing and not-so-accurate Wikipedia article, (*9)

This implementation is actually more an E(A)V model than a traditional EAV model because attributes are not stored in the database but in YAML files., (*10)

If you're not familiar with the key concepts of the EAV model, please read the following., (*11)

Why using it

  • Allowing ultra-fast model design because it's super easy to bootstrap.
  • Grouping in the same place the model and the metadata like: form configuration, validation, serialization options...
  • Managing single-value attributes and multiple-values attributes the same way and being able to change your mind after without having to do data recovery.
  • Storing contextual values per: locale, country, channel (web/print/mobile), versions.
  • Grouping and ordering attributes.
  • Easy CRUD: your forms are already configured !

Why not using it ?

Performances ? Not a real issue because MySQL is not usable for searching in a vast amount of data anyway, be it an EAV model or a more standard relational model. Solution: Elastic Search: it’s currently optionally supported through the Sidus/FilterBundle with the Sidus/ElasticaFilterBundle, (*12)

Relational model

If you a have a complex relational model and you plan to use a lots of joins to retrieve data, it might be best to keep your relational model outside of the EAV model but both can coexists without any problem. However, there is a technical limitation when using this implementation of the EAV model: There is only one table for the Data entry and one table for the Values., (*13)

The implementation

We are using Doctrine as it’s the most widely supported ORM by the Symfony community and we’re aiming at a MySQL/MariaDB implementation only for data storage., (*14)

In any EAV model there are two sides - The model itself: Families (data types), Attributes and Attribute Types. - The data: The values and the class that contains the values, called here “Data”., (*15)

In some implementation the model is stored in the database but here we chose to maintain the model in Symfony service configuration for several reasons:, (*16)

  • For performance reasons, you always needs to access a lots of components from your model and lazy loading will generate many unnecessary SQL requests. Symfony services are lazy loaded from PHP cache system which is very very fast compared to any other storage system.
  • For complexity reason: with services, you can always define new services, use injections, extend existing services and have complex behaviors for your entities.
  • A Symfony configuration is easy to write and to maintain and can be versioned, when your model is stored in your database along with your data you will have a very hard time to maintain the same model on your different environments.
  • Because the final users NEVER edits the model directly in production, it’s always some expert or some developer that does it on a testing environment first and we prefer simple yaml configuration files over a complex administration system that can fail.
  • It allows you to add layers of configuration for your special needs, for example you can configure directly some form options in the attribute declaration.
  • Finally, you can split your configuration and organise it in different files if needed be and you can comment it, which is a powerful feature when your model starts to grow bigger and bigger with hundreds of different attributes.

Families and attributes are services automatically generated from your configuration, attribute types are standard Symfony services., (*17)

Example

For a basic blog the configuration will look like this:, (*18)

sidus_eav_model:
    families:
        Post:
            attributeAsLabel: title
            attributes:
                title: # Default type is string
                    required: true

                content:
                    type: html # This type is available through the EAVBootstrapBundle

                publicationDate:
                    type: datetime

                publicationStatus:
                    type: choice
                    form_options: # Symfony form options are passed directly
                        choices:
                            draft: Draft
                            published: Published
                            archived: Archived

                author:
                    type: data_selector # This type allows to select an other entity inside the EAV model
                    options:
                        autoload: true # Autoload author when loading Post
                        allowed_families:
                            - Author

                tags:
                    multiple: true
                    form_options:
                        collection_options:
                            sortable: true

                isFeatured:
                    type: boolean

        Author:
            attributeAsLabel: name
            attributes:
                name:
                    required: true

                email:
                    validation_rules: # Validation rules can be applied directly in the model
                        - Email: ~

Note that by convention we declare the families in UpperCamelCase and the attributes as lowerCamelCase and we encourage you to do so., (*19)

The Versions

26/07 2018

dev-v1.2-dev

dev-v1.2-dev https://github.com/VincentChalnot/SidusEAVModelBundle

Symfony3 & Doctrine implementation of a Entity-Attribute-Value model, easily extendable

  Sources   Download

MIT

The Requires

 

model doctrine eav

26/07 2018

v1.2.20

1.2.20.0 https://github.com/VincentChalnot/SidusEAVModelBundle

Symfony3 & Doctrine implementation of a Entity-Attribute-Value model, easily extendable

  Sources   Download

MIT

The Requires

 

model doctrine eav

11/07 2018

v1.2.19

1.2.19.0 https://github.com/VincentChalnot/SidusEAVModelBundle

Symfony3 & Doctrine implementation of a Entity-Attribute-Value model, easily extendable

  Sources   Download

MIT

The Requires

 

model doctrine eav

19/06 2018

v1.2.18

1.2.18.0 https://github.com/VincentChalnot/SidusEAVModelBundle

Symfony3 & Doctrine implementation of a Entity-Attribute-Value model, easily extendable

  Sources   Download

MIT

The Requires

 

model doctrine eav

29/05 2018

v1.2.17

1.2.17.0 https://github.com/VincentChalnot/SidusEAVModelBundle

Symfony3 & Doctrine implementation of a Entity-Attribute-Value model, easily extendable

  Sources   Download

MIT

The Requires

 

model doctrine eav

25/04 2018

dev-v1.2.x-dev

dev-v1.2.x-dev https://github.com/VincentChalnot/SidusEAVModelBundle

Symfony3 & Doctrine implementation of a Entity-Attribute-Value model, easily extendable

  Sources   Download

MIT GPL-3.0 GPL-2.0 LGPL-3.0-or-later

The Requires

 

model doctrine eav

20/04 2018

v1.2.16

1.2.16.0 https://github.com/VincentChalnot/SidusEAVModelBundle

Symfony3 & Doctrine implementation of a Entity-Attribute-Value model, easily extendable

  Sources   Download

MIT

The Requires

 

model doctrine eav

12/04 2018

v1.2.15

1.2.15.0 https://github.com/VincentChalnot/SidusEAVModelBundle

Symfony3 & Doctrine implementation of a Entity-Attribute-Value model, easily extendable

  Sources   Download

MIT

The Requires

 

model doctrine eav

26/03 2018

v1.2.14

1.2.14.0 https://github.com/VincentChalnot/SidusEAVModelBundle

Symfony3 & Doctrine implementation of a Entity-Attribute-Value model, easily extendable

  Sources   Download

MIT

The Requires

 

model doctrine eav

21/03 2018

v1.2.13

1.2.13.0 https://github.com/VincentChalnot/SidusEAVModelBundle

Symfony3 & Doctrine implementation of a Entity-Attribute-Value model, easily extendable

  Sources   Download

MIT

The Requires

 

model doctrine eav

20/03 2018

v1.2.12

1.2.12.0 https://github.com/VincentChalnot/SidusEAVModelBundle

Symfony3 & Doctrine implementation of a Entity-Attribute-Value model, easily extendable

  Sources   Download

MIT

The Requires

 

model doctrine eav

20/03 2018

v1.2.11

1.2.11.0 https://github.com/VincentChalnot/SidusEAVModelBundle

Symfony3 & Doctrine implementation of a Entity-Attribute-Value model, easily extendable

  Sources   Download

MIT

The Requires

 

model doctrine eav

02/03 2018

v1.2.10

1.2.10.0 https://github.com/VincentChalnot/SidusEAVModelBundle

Symfony3 & Doctrine implementation of a Entity-Attribute-Value model, easily extendable

  Sources   Download

MIT

The Requires

 

model doctrine eav

08/01 2018

v1.2.9

1.2.9.0 https://github.com/VincentChalnot/SidusEAVModelBundle

Symfony2 & Doctrine implementation of a Entity-Attribute-Value model, easily extendable

  Sources   Download

GPL-3.0

The Requires

 

model doctrine eav

15/11 2017

dev-master

9999999-dev https://github.com/VincentChalnot/SidusEAVModelBundle

Symfony2 & Doctrine implementation of a Entity-Attribute-Value model, easily extendable

  Sources   Download

GPL-3.0 GPL-2.0

The Requires

 

model doctrine eav

15/11 2017

v1.2.8

1.2.8.0 https://github.com/VincentChalnot/SidusEAVModelBundle

Symfony2 & Doctrine implementation of a Entity-Attribute-Value model, easily extendable

  Sources   Download

GPL-3.0

The Requires

 

model doctrine eav

10/10 2017

v1.2.7

1.2.7.0 https://github.com/VincentChalnot/SidusEAVModelBundle

Symfony2 & Doctrine implementation of a Entity-Attribute-Value model, easily extendable

  Sources   Download

GPL-3.0

The Requires

 

model doctrine eav

21/09 2017

v1.2.6

1.2.6.0 https://github.com/VincentChalnot/SidusEAVModelBundle

Symfony2 & Doctrine implementation of a Entity-Attribute-Value model, easily extendable

  Sources   Download

GPL-3.0

The Requires

 

model doctrine eav

21/09 2017

v1.2.5

1.2.5.0 https://github.com/VincentChalnot/SidusEAVModelBundle

Symfony2 & Doctrine implementation of a Entity-Attribute-Value model, easily extendable

  Sources   Download

GPL-3.0

The Requires

 

model doctrine eav

19/09 2017

dev-v1.1.x-dev

dev-v1.1.x-dev https://github.com/VincentChalnot/SidusEAVModelBundle

Symfony2 & Doctrine implementation of a Entity-Attribute-Value model, easily extendable

  Sources   Download

GPL-2.0

The Requires

 

model doctrine eav

19/09 2017

v1.1.5

1.1.5.0 https://github.com/VincentChalnot/SidusEAVModelBundle

Symfony2 & Doctrine implementation of a Entity-Attribute-Value model, easily extendable

  Sources   Download

GPL-2.0

The Requires

 

model doctrine eav

23/08 2017

v1.2.4

1.2.4.0 https://github.com/VincentChalnot/SidusEAVModelBundle

Symfony2 & Doctrine implementation of a Entity-Attribute-Value model, easily extendable

  Sources   Download

GPL-3.0

The Requires

 

model doctrine eav

19/07 2017

v1.2.3

1.2.3.0 https://github.com/VincentChalnot/SidusEAVModelBundle

Symfony2 & Doctrine implementation of a Entity-Attribute-Value model, easily extendable

  Sources   Download

GPL-3.0

The Requires

 

model doctrine eav

11/07 2017

v1.2.2

1.2.2.0 https://github.com/VincentChalnot/SidusEAVModelBundle

Symfony2 & Doctrine implementation of a Entity-Attribute-Value model, easily extendable

  Sources   Download

GPL-3.0

The Requires

 

model doctrine eav

22/06 2017

v1.2.1

1.2.1.0 https://github.com/VincentChalnot/SidusEAVModelBundle

Symfony2 & Doctrine implementation of a Entity-Attribute-Value model, easily extendable

  Sources   Download

GPL-3.0

The Requires

 

model doctrine eav

13/06 2017

v1.2.0

1.2.0.0 https://github.com/VincentChalnot/SidusEAVModelBundle

Symfony2 & Doctrine implementation of a Entity-Attribute-Value model, easily extendable

  Sources   Download

GPL-2.0

The Requires

 

model doctrine eav

17/11 2016

v1.1.4

1.1.4.0 https://github.com/VincentChalnot/SidusEAVModelBundle

Symfony2 & Doctrine implementation of a Entity-Attribute-Value model, easily extendable

  Sources   Download

GPL-2.0

The Requires

 

model doctrine eav

03/11 2016

v1.1.3

1.1.3.0 https://github.com/VincentChalnot/SidusEAVModelBundle

Symfony2 & Doctrine implementation of a Entity-Attribute-Value model, easily extendable

  Sources   Download

GPL-2.0

The Requires

 

model doctrine eav

21/10 2016

v1.1.2

1.1.2.0 https://github.com/VincentChalnot/SidusEAVModelBundle

Symfony2 & Doctrine implementation of a Entity-Attribute-Value model, easily extendable

  Sources   Download

GPL-2.0

The Requires

 

model doctrine eav

20/10 2016

v1.1.1

1.1.1.0 https://github.com/VincentChalnot/SidusEAVModelBundle

Symfony2 & Doctrine implementation of a Entity-Attribute-Value model, easily extendable

  Sources   Download

GPL-2.0

The Requires

 

model doctrine eav

15/09 2016

v1.1.0

1.1.0.0 https://github.com/VincentChalnot/SidusEAVModelBundle

Symfony2 & Doctrine implementation of a Entity-Attribute-Value model, easily extendable

  Sources   Download

GPL-2.0

The Requires

 

model doctrine eav

30/03 2016

v1.0

1.0.0.0 https://github.com/VincentChalnot/SidusEAVModelBundle

Symfony2 & Doctrine implementation of a Entity-Attribute-Value model, easily extendable

  Sources   Download

GPL-2.0

The Requires

 

model doctrine eav

26/01 2016

v0.0.1

0.0.1.0 https://github.com/VincentChalnot/SidusEAVModelBundle

Symfony2 & Doctrine implementation of a Entity-Attribute-Value model, easily extendable

  Sources   Download

GPL-2.0

The Requires

 

model doctrine eav