gonzalo123/angularpostrequestserviceprovider

Angular POST Request Service Provider

dev-master / 1.0.x-dev 2015-03-04 19:32 UTC

This package is not auto-updated.

Last update: 2024-11-05 04:32:37 UTC


README

Build Status

When we work with AngularJs Applications POST request uses Content-Type: application/json Silex (and Symfony) assumes application/x-www-form-urlencoded Here we can se how to handle those requests with Silex: https://github.com/qandidate-labs/symfony-json-request-transformer

In this small project we are going to enclose this funcionality within a ServiceProvider

Install Via Composer

{
    "require": {
        "gonzalo123/angularpostrequestserviceprovider": "~1.0"
    }
}

Usage

use Silex\Application;
use G\AngularPostRequestServiceProvider;
use Symfony\Component\HttpFoundation\Request;

$app = new Application();
$app->register(new AngularPostRequestServiceProvider());

$app->post("/post", function (Application $app, Request $request) {
    return $app->json([
        'status' => true,
        'name'   => $request->get('name')
    ]);
});

$app->run();