gonzalo123/angularpostrequestserviceprovider

Angular POST Request Service Provider

Installs: 101

Dependents: 1

Suggesters: 0

Security: 0

Stars: 1

Watchers: 1

Forks: 0

Open Issues: 0

pkg:composer/gonzalo123/angularpostrequestserviceprovider

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

This package is not auto-updated.

Last update: 2025-10-07 09:01:01 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();