configuration.rst 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. Configuration
  2. =============
  3. Initial Configuration
  4. ---------------------
  5. JMSSerializerBundle requires no initial configuration to get you started.
  6. Reference
  7. ---------
  8. Below you find a reference of all configuration options with their default
  9. values:
  10. .. configuration-block ::
  11. .. code-block :: yaml
  12. # config.yml
  13. jms_serializer:
  14. handlers:
  15. datetime:
  16. default_format: "c" # ISO8601
  17. default_timezone: "UTC" # defaults to whatever timezone set in php.ini or via date_default_timezone_set
  18. property_naming:
  19. separator: _
  20. lower_case: true
  21. metadata:
  22. cache: file
  23. debug: "%kernel.debug%"
  24. file_cache:
  25. dir: "%kernel.cache_dir%/serializer"
  26. # Using auto-detection, the mapping files for each bundle will be
  27. # expected in the Resources/config/serializer directory.
  28. #
  29. # Example:
  30. # class: My\FooBundle\Entity\User
  31. # expected path: @MyFooBundle/Resources/config/serializer/Entity.User.(yml|xml|php)
  32. auto_detection: true
  33. # if you don't want to use auto-detection, you can also define the
  34. # namespace prefix and the corresponding directory explicitly
  35. directories:
  36. any-name:
  37. namespace_prefix: "My\\FooBundle"
  38. path: "@MyFooBundle/Resources/config/serializer"
  39. another-name:
  40. namespace_prefix: "My\\BarBundle"
  41. path: "@MyBarBundle/Resources/config/serializer"
  42. visitors:
  43. json:
  44. options: 0 # json_encode options bitmask
  45. xml:
  46. doctype_whitelist:
  47. - '<!DOCTYPE authorized SYSTEM "http://some_url">' # an authorized document type for xml deserialization
  48. .. code-block :: xml
  49. <!-- config.xml -->
  50. <jms-serializer>
  51. <handlers>
  52. <object-based />
  53. <datetime
  54. format="Y-mdTH:i:s"
  55. default-timezone="UTC" />
  56. <array-collection />
  57. <form-error />
  58. <constraint-violation />
  59. </handlers>
  60. <property-naming
  61. seperator="_"
  62. lower-case="true" />
  63. <metadata
  64. cache="file"
  65. debug="%kernel.debug%"
  66. auto-detection="true">
  67. <file-cache dir="%kernel.cache_dir%/serializer" />
  68. <!-- If auto-detection is enabled, mapping files for each bundle will
  69. be expected in the Resources/config/serializer directory.
  70. Example:
  71. class: My\FooBundle\Entity\User
  72. expected path: @MyFooBundle/Resources/config/serializer/Entity.User.(yml|xml|php)
  73. -->
  74. <directory
  75. namespace-prefix="My\FooBundle"
  76. path="@MyFooBundle/Resources/config/serializer" />
  77. </metadata>
  78. <visitors>
  79. <xml>
  80. <whitelisted-doctype><![CDATA[<!DOCTYPE...>]]></whitelisted-doctype>
  81. <whitelisted-doctype><![CDATA[<!DOCTYPE...>]]></whitelisted-doctype>
  82. </xml>
  83. </visitors>
  84. </jms-serializer>