gonzalo123 / angularpostrequestserviceprovider
Angular POST Request Service Provider
dev-master / 1.0.x-dev
2015-03-04 19:32 UTC
Requires
- silex/silex: >=v1.1.2, <2.0
This package is not auto-updated.
Last update: 2024-12-17 05:02:18 UTC
README
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();