SurveyJsBundle is just an integration of surveyjs library in Symfony 3.
- Install this bundle : composer require grelu/surveyjs-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(),
// ...
];
}
}
# app/config/routing.yml
surveyJs:
resource: "@SurveyJsBundle/Controller/"
type: annotation
php bin/console doctrine:schema:update --force
php bin/console assets:install
<?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;
}
<?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;
}
# SurveyJsBundle config
survey_js:
survey_class: AppBundle\Entity\Survey
data_survey_class: AppBundle\Entity\DataSurvey
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!