library angularpostrequestserviceprovider
Angular POST Request Service Provider
gonzalo123/angularpostrequestserviceprovider
Angular POST Request Service Provider
- Wednesday, March 4, 2015
- by gonzalo123
- Repository
- 1 Watchers
- 1 Stars
- 74 Installations
- PHP
- 1 Dependents
- 0 Suggesters
- 0 Forks
- 0 Open issues
- 1 Versions
- 0 % Grown
AngularPostRequestServiceProvider
, (*1)
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, (*2)
In this small project we are going to enclose this funcionality within a ServiceProvider, (*3)
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();
dev-master
9999999-dev
Angular POST Request Service Provider
Sources
Download
MIT
The Requires
rest
silex
angular