@@ -817,13 +817,6 @@ The ``CsvEncoder``
817817
818818The ``CsvEncoder `` encodes to and decodes from CSV.
819819
820- You can pass the context key ``as_collection `` in order to have the results
821- always as a collection.
822-
823- ..deprecated ::4.2
824-
825- Relying on the default value ``false `` is deprecated since Symfony 4.2.
826-
827820The ``XmlEncoder ``
828821~~~~~~~~~~~~~~~~~~
829822
@@ -1260,6 +1253,52 @@ These are the options available:
12601253``remove_empty_tags ``
12611254 If set to true, removes all empty tags in the generated XML (default: ``false ``).
12621255
1256+ The ``CsvEncoder ``
1257+ ------------------
1258+
1259+ This encoder transforms arrays into CSV and vice versa.
1260+
1261+ Context
1262+ ~~~~~~~
1263+
1264+ The ``encode() `` method defines a third optional parameter called ``context ``
1265+ which defines the configuration options for the CsvEncoder an associative array::
1266+
1267+ $csvEncoder->encode($array, 'csv', $context);
1268+
1269+ These are the options available:
1270+
1271+ ``csv_delimiter ``
1272+ Sets the field delimiter separating values (one character only, default: ``, ``).
1273+
1274+ ``csv_enclosure ``
1275+ Sets the field enclosure (one character only, default: ``" ``).
1276+
1277+ ``csv_escape_char ``
1278+ Sets the escape character (at most one character, default: empty string).
1279+
1280+ ``csv_key_separator ``
1281+ Sets the separator for array's keys during its flattening (default: ``. ``).
1282+
1283+ ``csv_headers ``
1284+ Sets the headers for the data (default: ``[] ``, inferred from input data's keys).
1285+
1286+ ``csv_escape_formulas ``
1287+ Escapes fields containg formulas by prepending them with a ``\t `` character (default: ``false ``).
1288+
1289+ ``as_collection ``
1290+ Always returns results as a collection, even if only one line is decoded (default: ``false ``).
1291+
1292+ ..deprecated ::4.2
1293+
1294+ Relying on the default value ``false `` is deprecated since Symfony 4.2.
1295+
1296+ ``no_headers ``
1297+ Disables header in the encoded CSV (default: ``false ``).
1298+
1299+ ``output_utf8_bom ``
1300+ Outputs special `UTF-8 BOM `_ along with encoded data (default: ``false ``).
1301+
12631302Handling Constructor Arguments
12641303------------------------------
12651304
@@ -1514,6 +1553,7 @@ Learn more
15141553.. _YAML :https://yaml.org/
15151554.. _CSV :https://tools.ietf.org/html/rfc4180
15161555.. _`RFC 7807` :https://tools.ietf.org/html/rfc7807
1556+ .. _`UTF-8 BOM` :https://en.wikipedia.org/wiki/Byte_order_mark
15171557.. _`Value Objects` :https://en.wikipedia.org/wiki/Value_object
15181558.. _`API Platform` :https://api-platform.com
15191559.. _`list of PHP timezones` :https://www.php.net/manual/en/timezones.php