Advertisement
Guest User

Untitled

a guest
Jan 5th, 2016
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.62 KB | None | 0 0
  1. acme_api_register:
  2. pattern: /user
  3. defaults: { _controller: AcmeApiBundle:User:post, _format: json }
  4. requirements:
  5. _method: POST
  6.  
  7. <?php
  8.  
  9. namespace AcmeApiBundleController;
  10.  
  11. use AcmeApiBundleEntityPatient;
  12. use AcmeApiBundleEntityUser;
  13. use SymfonyBundleFrameworkBundleControllerController;
  14. use SymfonyComponentHttpFoundationRequest;
  15. use SymfonyComponentHttpFoundationResponse;
  16. use FOSRestBundleControllerAnnotationsView;
  17.  
  18. //use FOSRestBundleViewView;
  19.  
  20. class UserController extends Controller
  21. {
  22. /**
  23. * @View()
  24. */
  25. public function postAction()
  26. {
  27. $user = new Patient();
  28.  
  29. $user->setName("Daniel");
  30. $user->setLastName("My lastName");
  31. $user->setEmail("pleasework@gmail.com");
  32.  
  33. return $user;
  34. }
  35. }
  36.  
  37. sensio_framework_extra:
  38. view: { annotations: false}
  39. router: { annotations: true }
  40.  
  41. fos_rest:
  42. format_listener:
  43. rules:
  44. - prefer_extension: false
  45. routing_loader:
  46. default_format: json
  47. view:
  48. view_response_listener: force
  49.  
  50. {
  51. "name": "symfony/framework-standard-edition",
  52. "license": "MIT",
  53. "type": "project",
  54. "description": "The "Symfony Standard Edition" distribution",
  55. "autoload": {
  56. "psr-0": { "": "src/" }
  57. },
  58. "require": {
  59. "php": ">=5.3.3",
  60. "symfony/symfony": "~2.4",
  61. "doctrine/orm": "~2.2,>=2.2.3",
  62. "doctrine/doctrine-bundle": "~1.2",
  63. "twig/extensions": "~1.0",
  64. "symfony/assetic-bundle": "~2.3",
  65. "symfony/swiftmailer-bundle": "~2.3",
  66. "symfony/monolog-bundle": "~2.4",
  67. "sensio/distribution-bundle": "~2.3",
  68. "sensio/framework-extra-bundle": "~3.0",
  69. "sensio/generator-bundle": "~2.3",
  70. "incenteev/composer-parameter-handler": "~2.0",
  71. "friendsofsymfony/rest-bundle": "1.1.*",
  72. "jms/serializer-bundle": "0.13.*"
  73. },
  74. "scripts": {
  75. "post-install-cmd": [
  76. "Incenteev\ParameterHandler\ScriptHandler::buildParameters",
  77. "Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::buildBootstrap",
  78. "Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::clearCache",
  79. "Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::installAssets",
  80. "Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::installRequirementsFile"
  81. ],
  82. "post-update-cmd": [
  83. "Incenteev\ParameterHandler\ScriptHandler::buildParameters",
  84. "Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::buildBootstrap",
  85. "Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::clearCache",
  86. "Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::installAssets",
  87. "Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::installRequirementsFile"
  88. ]
  89. },
  90. "config": {
  91. "bin-dir": "bin"
  92. },
  93. "extra": {
  94. "symfony-app-dir": "app",
  95. "symfony-web-dir": "web",
  96. "symfony-assets-install": "symlink",
  97. "incenteev-parameters": {
  98. "file": "app/config/parameters.yml"
  99. },
  100. "branch-alias": {
  101. "dev-master": "2.4-dev"
  102. }
  103. }
  104. }
  105.  
  106. Accept:text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
  107.  
  108. fos_rest:
  109. param_fetcher_listener: true
  110. format_listener:
  111. rules:
  112. fallback_format: json
  113. prefer_extension: false
  114. priorities: [json, xml]
  115. view:
  116. view_response_listener: force
  117. formats:
  118. json: true
  119. xml: true
  120. jsonp: false
  121. rss: false
  122. html: false
  123. failed_validation: HTTP_BAD_REQUEST
  124.  
  125. <?php
  126.  
  127. namespace AcmeApiBundleController;
  128.  
  129. use AcmeApiBundleEntityPatient;
  130. use AcmeApiBundleEntityUser;
  131. use SymfonyComponentHttpFoundationRequest;
  132. use SymfonyComponentHttpFoundationResponse;
  133. use FOSRestBundleControllerAnnotationsView;
  134. use FOSRestBundleControllerFOSRestController;
  135.  
  136.  
  137. class UserController extends FOSRestController
  138. {
  139. /**
  140. * @View()
  141. */
  142. public function postUserAction()
  143. {
  144. $user = new Patient();
  145.  
  146. $user->setName("Daniel");
  147. $user->setLastName("My lastName");
  148. $user->setEmail("pleasework@gmail.com");
  149.  
  150. return $user;
  151. }
  152. }
  153.  
  154. users:
  155. type: rest
  156. resource: AcmeApiBundleControllerUsersController
  157.  
  158. #...
  159. fos_rest:
  160. view:
  161. view_response_listener: force
  162. format_listener:
  163. default_priorities: ['json', 'html', '*/*']
  164. fallback_format: json
  165. prefer_extension: true
  166. #...
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement