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

ssa bundle for use ssa framework into Symfony

v1.0.1 2014-09-06 19:11 UTC


Ssa is a framework for access to your php service in your javascript code. This project is the ssa integration on symfony 2. Ssa project


Ssa bundle installation is very simple, you need just to add composer dependency.


"require": {
  "ssa/ssa-bundle" : "dev-master",

If composer say "ssa/core" not found add this line in your composer file : composer.json

"require": {
  "ssa/core" : "dev-master",

Add the bundle in your kernel :

new Ssa\SsaBundle\SsaBundle()

Add the ssa routing in your routing.yml


    resource: "@SsaBundle/Resources/config/routing.yml"

After you can register your services into config.yml


ssa :
    services :
        # serviceName is the ssa service name
        # service : is the symfony serivce
        serviceName : {service : 'ssa.test.service'}
        # or you can just export any methods of this service
        serviceName2 : {service : 'ssa.test.service', methods : ['methodToImport']}
        # if your service is not a symfony service you can use the class attribute
        serviceName3 : {class : '\Path\To\Your\Class', methods : ['methodToImport']}      

And you can Simply import the javascript service with assetic, like this :


{% javascripts 
<script type="text/javascript" src="{{asset_url }}"></script>
{% endjavascripts  %}

you can now simply call your php service into your javascript file :

    .methodToImport('param1', {objectProp : 'ObjectValue', objectProp2 : 'ObjectValue2'})


Ssa allow to call php service into javascript code. Ssa in symfony add a parameter resolver. It can convert json oject into your doctrine entity. Example : Entity

Product :
  - id
  - name
  - price


Id | Name | Price

1 | Foo | 10.0


class ProductService {
    private $em;
    public function __construct(EntityManagerInterface $em) {
        $this->em = $em;
    public function getProduct(Product $p) {
        return $p;

    public function updateProduct(Product $p) {
        return $p;

Javascript call :

productService.getProduct({id : 1}).done(function(data){
  // = 1
  // = "Foo"
  // data.price = 10.0

productService.updateProduct({name : 'Bar', price : 15}).done(function(data){
  // = AutoGenerated value
  // = 'Bar'
  // data.price = 15

productService.updateProduct({id : 1, price : 11.5}).done(function(data){
  // = 1
  // = 'Foo'
  // data.price = 11.5


You can customize the framework with you own classes or change parameters.


You can change any parameters on config.yml


ssa :
    configuration :
        # the debug configuration, default is the symfony configuration
        debug : true | false
        # the cache configuration, by default there are no cache, the cachemode is not mandatory with symfony
        cacheMode : file | apc | memcache
        # the cache directory if cacheMode is file. default it's the kernel.cache_dir
        cacheDirectory : 
        # the host for memcache cacheMode
        memcacheHost :
        # the port for memcache cacheMode
        memcachePort :
        # path to ssa js file, if you have your own ssa js implementation. Path begin in web directory
        ssaJsFile :

You can add your own resolver, if you want use specific resolver for your own class : Ssa documentation


ssa :
    parameterResolver :
        primitive :
            - YourFirstPrimitiveResolver
            - YoutSecondPrimitiveResolver
        object :
            - YourFirstObjectResolver
            - YourSecondObjectResolver


You can change ssa implementation, add ssa parameters resolver, change route generator.

Route manager

Routes are use for generate url to call php services, by default the ssa_run_service route is used. You have two way for change route generation. The first is to change the route name used :


parameters :
    ssa.runner.route : 'your_own_ssa_route_name'

Or you can completly change the class use for generate route, your class must implements ssa\converter\UrlFactory interface, your constructor must have two parameters Symfony\Component\Routing\RouterInterface $router and $routeName. For change the class used you must change the ssa.urlFactory.class parameter :


parameters :
    ssa.runner.route : Your\Own\UrlFactory
Parameter resolver

If you want use your own parameter resolver, you can set the class used. the parameter resolver is used for convert get or post parameter in php object. Your parameter resolver need to extends ssa\runner\resolver\impl\DefaultParameterResolver or implements ssa\runner\resolver\ParameterResolver. Your must change the parameter ssa.parameterResolver.class for use your own parameterResolver.


parameters :
    ssa.parameterResolver.class : Your\own\resolver