fosrestbundle

RESTFul OAuth with FOSOAuthServer / FOSRest & FOSUser

风格不统一 提交于 2019-12-24 00:37:02
问题 I'm having difficulties to fully understand the concept of the client creation explained here. I followed the post to set up the OAuthBundle, and tried to make the changes needed to comply with FOSUser. Though I'm not sure it's perfect. My situation My Website is a RESTFul API, which return json or xml only. My frontend will be in AngularJS I combined FOSUser, FOSRest and FOSOAuth, it's possible I'm having errors in the configuration. The Problem I finished setting up the first part of the

How to configure FOSRestBundle to not interfere with Custom Exception Controller

白昼怎懂夜的黑 提交于 2019-12-23 15:08:23
问题 I have just updated my Symfony 2.7 page to 2.8. Beside Symfony itself a number of other packages have been updated as well. FOSRestBundle has been updated from version 1.4 to 2.1. After the update the CustomExceptionController I configured for Twig does not work any more. Error like 404 or 500 show the default exception page instead of my custom page. This is the configuration: // app/config/config.yml ... twig: exception_controller: app.exception_controller:showAction // src/MyAppBundle

FOSRestBundle configuration of exceptions messages in prod environment

馋奶兔 提交于 2019-12-23 12:09:26
问题 I'm struggling with a problem linked to the FOSRestBundle (version 0.13.*) I have some REST api that throws some exceptions, nothing unusual I guess. But, despite the specific configuration I made to allow exceptions messages to be formatted in the response even in production (following the documentation I found here : https://github.com/FriendsOfSymfony/FOSRestBundle/blob/master/Resources/doc/4-exception-controller-support.md), the JSON response stays desperately empty... Example below: http

routing.yml import when using FOSRestBundle

夙愿已清 提交于 2019-12-23 03:54:16
问题 I follow tutorial in here (http://npmasters.com/2012/11/25/Symfony2-Rest-FOSRestBundle.html) about using FOSRestBundle. When setting up the route, I get error : Cannot import resource "D:\xampp\htdocs\SymRestTestApp\src\Per\RestBundle/Resources/config/routing.yml" from "D:/xampp/htdocs/SymRestTestApp/app/config\routing.yml". My app/config/routing.yml per_rest: resource: "@PerRestBundle/Controller" type: annotation prefix: / per: type: rest resource: "@PerRestBundle/Resources/config/routing

Symfony2 OAuth keeps giving me a login page when a token is provided

淺唱寂寞╮ 提交于 2019-12-22 17:49:27
问题 I have setup an app with: FriendsOfSymfony/FOSUserBundle FriendsOfSymfony/FOSOAuthServerBundle FriendsOfSymfony/FOSRestBundle I have successfully created a client and can get an access token using a url like this http://api.mydomain.com/oauth/v2/token?client_id=CLIENT_ID&client_secret=CLIENT_SECRET&grant_type=password&username=mikebates&password=secret However, when I then try to access the a url like this http://api.mydomain.com/api/surgeries/45/details?access_token=ACCESS_TOKEN I get

Add custom property to serialized object

依然范特西╮ 提交于 2019-12-22 16:40:44
问题 I'm developing RESTful API for a web service. And I need to expose some properties that do not belong to an entity itself. For example I have a Pizza entity object, it has it's own size and name properties. I'm outputting it in JSON format with FOSRestBundle and JMSSerializer . I've setup properties annotations for this entity to expose needed properties via serialization groups and it's working great. But I need to add some properties that do not belong to the entity itself. For example I

FosRestBundle post/put [create new/update entity] does not read Request correctly

删除回忆录丶 提交于 2019-12-22 04:12:39
问题 long story short: Using FOSRestBundle I'm trying to create some entities via POST call, or modify existing via PUT. here the code: /** * Put action * @var Request $request * @var integer $id Id of the entity * @return View|array */ public function putCountriesAction(Request $request, $id) { $entity = $this->getEntity($id); $form = $this->createForm(new CountriesType(), $entity, array('method' => 'PUT')); $form->bind($request); if ($form->isValid()) { $em = $this->getDoctrine()->getManager();

FOSRestBundle doesn't work in Symfony 4.1

限于喜欢 提交于 2019-12-21 09:09:53
问题 I have problem with returning views with FOSRestBundle working under Symfony 4.1 Project. This is code from my controller: class NewsController extends FOSRestController { public function getNewsAction() { $data = ['news1', 'news2']; $view = $this->view($data, 200); return $this->handleView($view); } } fos_rest.yaml fos_rest: param_fetcher_listener: true allowed_methods_listener: true routing_loader: true view: view_response_listener: 'force' format_listener: rules: - { path: ^/api, prefer

multipart/form-data and FormType validation

十年热恋 提交于 2019-12-20 12:38:26
问题 I am building an API using the FOSRestBundle and am at the stage where I need to implement the handling of the creation of new entities that contain binary data. Following the methods outlined on Sending binary data along with a REST API request sending the data as multipart/form-data feels the most practical for our implementation due to the ~33% added bandwidth required for Base64. Question How can I configure the REST end point to both handle the file within the request and perform

symfony2 FOSRestBundle annotations

雨燕双飞 提交于 2019-12-20 09:43:27
问题 Is anyone used put, get, post, delete annotations(https://github.com/FriendsOfSymfony/FOSRestBundle/blob/master/Controller/Annotations/) in controller. I'm trying to use it like this, but it still takes get methods. What is the purpose of those Annotations in FOSRestBundle /** * @Route("/get/{id}", defaults={"_format" = "json"}) * @Post */ public function getObject($id) { $object = $this->getService()->findById($id); return $object; } 回答1: I want to share info about all annotations. @Get,