grelu/surveyjs-bundle

There is no license information available for the latest version (0.1) of this package.

SurveyJs Bundle

Installs: 76

Dependents: 0

Suggesters: 0

Security: 0

Stars: 3

Watchers: 3

Forks: 1

Open Issues: 0

Language:JavaScript

Type:symfony-bundle

0.1 2017-11-20 10:09 UTC

This package is not auto-updated.

Last update: 2024-05-12 02:28:00 UTC


README

SurveyJsBundle is just an integration of surveyjs library in Symfony 3.

How to

  • Install this bundle : composer require grelu/surveyjs-bundle

Enable the bundle

To start using the bundle, register the bundle in your application's kernel class:

// app/AppKernel.php
class AppKernel extends Kernel
{
    public function registerBundles()
    {
        $bundles = [
            // ...
            new Grelu\SurveyJsBundle\SurveyJsBundle(),
            // ...
        ];
    }
}

Enable routing

# app/config/routing.yml
surveyJs:
    resource: "@SurveyJsBundle/Controller/"
    type:     annotation

Update schema :

php bin/console doctrine:schema:update --force

Install Assets :

php bin/console assets:install

You must now to extend two class in your AppBundle :

Add Class Survey (to save your surveys ) :

<?php

namespace AppBundle\Entity;

use Grelu\SurveyJsBundle\Entity\Survey as BaseSurvey;
use Doctrine\ORM\Mapping as ORM;

/**
 * @ORM\Entity
 * @ORM\Table(name="survey")
 */
class Survey extends BaseSurvey
{
    /**
     * @ORM\Id
     * @ORM\Column(type="integer")
     * @ORM\GeneratedValue(strategy="AUTO")
     */
    protected $id;
}

Add Class DataSurvey (to save results of surveys)

<?php

namespace AppBundle\Entity;

use Grelu\SurveyJsBundle\Entity\DataSurvey as BaseDataSurvey;
use Doctrine\ORM\Mapping as ORM;

/**
 * @ORM\Entity
 * @ORM\Table(name="data_survey")
 */
class DataSurvey extends BaseDataSurvey
{
    /**
     * @ORM\Id
     * @ORM\Column(type="integer")
     * @ORM\GeneratedValue(strategy="AUTO")
     */
    protected $id;
}

Add class in your config.yml

# SurveyJsBundle config
survey_js:
    survey_class: AppBundle\Entity\Survey
    data_survey_class: AppBundle\Entity\DataSurvey

It's Ok ! This is the list of routes available :

survey_index GET ANY ANY /survey/
survey_new_edit GET|POST ANY ANY /survey/edit/{id}
survey_save POST ANY ANY /survey/save
survey_show GET ANY ANY /survey/show/{id}/number/{number}
survey_data_save POST ANY ANY /survey/data-save

Enjoy!