liip/LiipMultiplexBundle

Name: LiipMultiplexBundle

Owner: Liip

Description: [DEPRECATED] Symfony2 controller that allows calling multiple URL's in one request as well as JSON-ifying any controller

Created: 2010-10-28 07:37:45.0

Updated: 2017-12-05 09:28:14.0

Pushed: 2017-12-05 09:28:02.0

Homepage: http://liip.ch

Size: 84

Language: PHP

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

UNMAINTAINED

This bundle is no longer maintained. Feel free to fork it if needed.

Overview Build Status

This Bundles enables “multiplexing” multiple requests into a single Request/Response:

for example this request:

http://foo.com/multiplex.json?requests[login][uri]=/session/new&requests[notification][uri]=/notifications&requests[notification][method]=get&requests[notification][parameters][]=broadcasts&requests[notification][parameters][]=personal

will internally call:

/session/new and /notifications

and return one Response:


"/session/new"   : {"request" : "/session/new", "status": 200, "response": "the Response Content of /session/new"},
"/notifications" : {"request" : "/notifications", "status": 403, "response": "Forbidden"}

Attention: Installing this Bundle basically lets anyone side step the security firewall. Therefore its important to either secure the multiplex route or to implement security checks inside all relevant controllers

Installation

  1. Add this bundle to your project with Composer:

    p composer.phar require liip/multiplex-bundle
    
  2. Add this bundle to your application's kernel:

     app/AppKernel.php
    blic function registerBundles()
    
      return array(
          // ...
          new Liip\MultiplexBundle\LiipMultiplexBundle(),
          // ...
      );
    
    

Configuration

The following Configuration Options exists:

Application Configuration

here the default config

_multiplex:
allow_externals: true
display_errors: true
route_option: 'multiplex_expose'
restrict_routes: false
Routing Configuration

if you want to restrict multiplexing to specific routes, define the option in each route you want to expose

te id="_my_route" pattern="/foo/bar">
<default key="_controller">MyBundle:Controller:index</default>
<option key="multiplex_expose">true</option>
ute>

and don't forget to set restrict_routes to true!

Usage

This Bundles provides a decent Javascript Library to use the Multiplexer Endpoint.

Integration of the Javascript
 javascripts
LiipMultiplexBundle/Resources/public/js/ajax_multiplexer.js"
output='js/multiplexer.js'

<script src="{{ asset_url }}"></script>
 endjavascripts %}
Using the Javascript Multiplexer
nfiguring the Multiplexer
iplexer.setEndpoint('/path/to/multiplexer/endpoint'); //as in your routing defaults to /multiplex.json
iplexer.setFormat('json'); //only useful exchange format

ding Requests to the Multiplexer
iplexer.add(
{'uri' : '/foo/bar', 'method' : 'GET', 'parameters' : {'foo':'bar'}}, //the Request Object
function(content) { /* ... */}, // the Success Callback
function(content) { /* ... */}  // the Error Callback


iplexer.add(
{'uri' : 'http://google.com', 'method' : 'GET', 'parameters' : {'q':'Symfony2'}},
function(content) { /* this callback is called on success for this request*/},
function(content) { /* this callback is called on error for this request*/}


shing all Requests to the Server
iplexer.call(
function(r){ /* ... */ }, //the global success callback (optional)
function(r){ /* ... */ } //the global error callback (optional)


shing only a set of Requests to the Server
iplexer.call(['/foo/bar']);

Tests

  1. To run the unit tests, require all dependencies

    p composer.phar update --dev
    
  2. Run PHPUnit

    punit
    
  3. See Travis for automated Tests

    https://travis-ci.org/liip/LiipMultiplexBundle

TODO


This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.