PHPackages                             sst/survey-lib-bundle - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. sst/survey-lib-bundle

ActiveSymfony-bundle

sst/survey-lib-bundle
=====================

Symfony Bundle For Surveys

2.4.0(2mo ago)7924↓100%3[1 issues](https://github.com/sst-software/SurveyLib/issues)MITPHPPHP &gt;=8.1

Since Nov 1Pushed 2mo ago3 watchersCompare

[ Source](https://github.com/sst-software/SurveyLib)[ Packagist](https://packagist.org/packages/sst/survey-lib-bundle)[ RSS](/packages/sst-survey-lib-bundle/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (13)Versions (16)Used By (0)

SST Survey Library Bundle
=========================

[](#sst-survey-library-bundle)

This bundle provides a library of survey-related Entities and Services for Symfony projects.

License
=======

[](#license)

This bundle is developed by SST Software, see LICENSE for more details.

Installation
============

[](#installation)

- Run `composer require sst/survey-lib-bundle`
- Create Entities, based on the interfaces in `Interfaces/Entity` (see below)

Contents
========

[](#contents)

Entities
--------

[](#entities)

This bundle provides interfaces and traits to fulfill these, for a general Survey application.

The bundle assumes that these entities are stored in the `App\Entity\Survey` namespace, if this is not the case, you can change this in the configuration (see below).

Available Entities with their Traits and Interfaces are:

- Survey: The basis of a survey, contains a list of containers
    - Trait: `Sst\SurveyLibBundle\Entity\Traits\SurveyTrait`
    - Interface: `Sst\SurveyLibBundle\Interfaces\Entity\SurveyInterface`
- Container: A container for one or more element-usages or one or more child-containers (use either one, combinations of child-containers and element-usages are not allowed)
    - Trait: `Sst\SurveyLibBundle\Entity\Traits\ContainerTrait`
    - Interface: `Sst\SurveyLibBundle\Interfaces\Entity\ContainerInterface`
- Element: The basis of a survey-element, which can be e.g. a question, or a piece of text.
    - Trait: `Sst\SurveyLibBundle\Entity\Traits\ElementTrait`
    - Interface: `Sst\SurveyLibBundle\Interfaces\Entity\ElementInterface`
- ElementUsage: An element-usage is a reference to an element, which can be used in a container.
    - Trait: `Sst\SurveyLibBundle\Entity\Traits\ElementUsageTrait`
    - Interface: `Sst\SurveyLibBundle\Interfaces\Entity\ElementUsageInterface`
- SurveyResponse: A group of answers, which is the result of a survey being filled in.
    - Trait: `Sst\SurveyLibBundle\Entity\Traits\SurveyResponseTrait`
    - Interface: `Sst\SurveyLibBundle\Interfaces\Entity\SurveyResponseInterface`
- Answer: Contains the given answer to an ElementUsage
    - Trait: `Sst\SurveyLibBundle\Entity\Traits\AnswerTrait`
    - Interface: `Sst\SurveyLibBundle\Interfaces\Entity\AnswerInterface`

### Datamodel

[](#datamodel)

[![Datamodel](docs/datamodel.png "Datamodel")](docs/datamodel.png)

### The Element entity and ElementData

[](#the-element-entity-and-elementdata)

The Element entity has a parameter `elementData`, in which all data regarding the element can be stored. ElementData matches the `type` of the Element, so make sure you set a valid combination of `type` and `ElementData`when creating an Element

This bundle provides several default ElementData types:

**ElementType****ElementData****Description**TEXTTextQuestionElementDataInterfaceQuestion which can be answered with a textNUMBERNumberQuestionElementDataInterfaceQuestion which can be answered with a numberDATETIMEDateTimeQuestionElementDataInterfaceQuestion which can be answered with a date or datetimeMULTIPLE\_CHOICEMultipleChoiceQuestionElementDataInterfaceMultiple choice questionMULTIPLE\_CHOICE\_GRIDMultipleChoiceGridQuestionElementDataInterfaceQuestion providing a grid of multiple multiple-choice-questionsSCALEScaleQuestionElementDataInterfaceQuestion that can be shown as scaleINFOElementDataInterfaceInfo-text, to be shown during a surveyCUSTOMCustomElementDataInterfaceCustom ElementData, to allow for project-specific implementationsYou can extend or overwrite these, as long as your ElementData implements the correct interface, matching the `type` of the Element.

### Display conditions

[](#display-conditions)

This bundle provides a service to check if a given ElementUsage should be displayed, based on a given SurveyResponse.
To identify elements, it uses the `code` parameter of the ElementUsage.
The provided `displayConditionService` assumes that `ElementUsage->display_condition` contains a valid expression, see [Symfony Expression Language](https://symfony.com/doc/current/components/expression_language.html).
So make sure, this code is unique in the set you are checking, usually this means, that it should be unique in the related survey.

Services
--------

[](#services)

This bundle contains several services to use in your survey-project. These are injected automatically when using their interfaces. This can be overridden by providing a configuration file (see below).

- `createSurveyResponseService`: Creates a new SurveyResponse, linked to the given survey, with stored start-date and shuffled element-order (if applicable)
- `displayConditionService`: Checks if the given ElementUsage should be displayed, based on a given SurveyResponse, also provided functions to get the condition as php or as javascript
- `astToJavascriptService`: Converts an AST to javascript
- `nextElementService`: Gets the next ElementUsage to display for a SurveyResponse, can also be used to get the previous item, by setting `$reverse` to true
- `addAnswerService`: Adds one or more answers to a SurveyResponse, based on the given ElementUsage and the given rawAnswer
- `validateAnswerService`: Validates the given answer for a given ElementUsage

Customization
=============

[](#customization)

You can customize which class implements which interface by providing a configuration file in your project.
If you want to do so, create a file `config/packages/sst_survey_lib.yaml` with the following contents:

```
sst_survey_lib:
    services:
        createSurveyResponseService: Sst\SurveyLibBundle\Service\CreateSurveyResponseService
        displayConditionService: Sst\SurveyLibBundle\Service\DisplayConditionService
        astToJavascriptService: Sst\SurveyLibBundle\Service\AstToJavascriptService
        nextElementService: Sst\SurveyLibBundle\Service\NextElementService
        addAnswerService: Sst\SurveyLibBundle\Service\AddAnswerService
        validateAnswerService: Sst\SurveyLibBundle\Service\ValidateAnswerService
    entities:
        survey: App\Entity\Survey
        container: App\Entity\Container
        element: App\Entity\Element
        elementOverride: Sst\SurveyLibBundle\Entity\ElementOverride
        elementUsage: App\Entity\ElementUsage
        surveyResponse: App\Entity\SurveyResponse
        answer: App\Entity\Answer
    typeMappings:
        elementData: Sst\SurveyLibBundle\Types\ElementDataType
        rawAnswer: Sst\SurveyLibBundle\Types\RawAnswerType
        elementOverride: Sst\SurveyLibBundle\Types\ElementOverrideType
```

These are the default values, if these are the values you need, you don't need to create the file. If you need to change this, copy (parts of) above code into this file.

Events
======

[](#events)

This bundle provides a few events, which you can listen to.

- `SurveyResponseCreate::PRE_CREATE` is dispatched before a survey-response is created
- `SurveyResponseCreate::POST_CREATE` is dispatched after a survey-response is created
- `AnswerCreate::PRE_CREATE` is dispatched before an answer is created
- `AnswerCreate::POST_CREATE` is dispatched after an answer is created
- `AnswerCreate::PRE_UPDATE` is dispatched before an answer is updated
- `AnswerCreate::POST_UPDATE` is dispatched after an answer is updated
- `AnswerCreate::PRE_VALIDATE` is dispatched before an answer is validated
- `AnswerCreate::POST_VALIDATE` is dispatched after an answer is validated

###  Health Score

48

—

FairBetter than 94% of packages

Maintenance84

Actively maintained with recent releases

Popularity25

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity59

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 62.5% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~61 days

Recently: every ~95 days

Total

15

Last Release

66d ago

Major Versions

1.1.0 → 2.0.02024-08-12

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/47625921?v=4)[SST Software](/maintainers/SST-software)[@sst-software](https://github.com/sst-software)

---

Top Contributors

[![maartennowee](https://avatars.githubusercontent.com/u/69148348?v=4)](https://github.com/maartennowee "maartennowee (5 commits)")[![xrogers](https://avatars.githubusercontent.com/u/1160871?v=4)](https://github.com/xrogers "xrogers (3 commits)")

---

Tags

symfonysurveylibsstsurvey libsurveylibsurveylib-bundle

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/sst-survey-lib-bundle/health.svg)

```
[![Health](https://phpackages.com/badges/sst-survey-lib-bundle/health.svg)](https://phpackages.com/packages/sst-survey-lib-bundle)
```

###  Alternatives

[sylius/sylius

E-Commerce platform for PHP, based on Symfony framework.

8.4k5.6M650](/packages/sylius-sylius)[sulu/sulu

Core framework that implements the functionality of the Sulu content management system

1.3k1.3M152](/packages/sulu-sulu)[prestashop/prestashop

PrestaShop is an Open Source e-commerce platform, committed to providing the best shopping cart experience for both merchants and customers.

9.0k15.4k](/packages/prestashop-prestashop)[ec-cube/ec-cube

EC-CUBE EC open platform.

78527.0k1](/packages/ec-cube-ec-cube)[easycorp/easyadmin-bundle

Admin generator for Symfony applications

4.3k16.7M309](/packages/easycorp-easyadmin-bundle)[contao/core-bundle

Contao Open Source CMS

1231.6M2.3k](/packages/contao-core-bundle)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
