The code should follow the Symfony Best Practices.
Unless the example requires a custom bundle, make sure to always use the
AppBundle bundle to store your code;

Use Acme when the code requires a vendor name;

Use example.com as the domain of sample URLs and example.org and
example.net when additional domains are required. All of these domains are
reserved by the IANA.

To avoid horizontal scrolling on code blocks, we prefer to break a line
correctly if it crosses the 85th character;

When you fold one or more lines of code, place ... in a comment at the point
of the fold. These comments are: // ... (php), # ... (yaml/bash), {# ... #}
(twig), <!-- ... --> (xml/html), ; ... (ini), ... (text);

When you fold a part of a line, e.g. a variable value, put ... (without comment)
at the place of the fold;

Description of the folded code: (optional)

If you fold several lines: the description of the fold can be placed after the ...;

If you fold only part of a line: the description can be placed before the line;

If useful to the reader, a PHP code example should start with the namespace
declaration;

When referencing classes, be sure to show the use statements at the
top of your code block. You don't need to show alluse statements
in every example, just show what is actually being used in the code block;

If useful, a codeblock should begin with a comment containing the filename
of the file in the code block. Don't place a blank line after this comment,
unless the next line is also a comment;

// src/Foo/Bar.phpnamespaceFoo;useAcme\Demo\Cat;// ...classBar{// ...publicfunctionfoo($bar){// set foo with a value of bar$foo=...;$cat=newCat($foo);// ... check if $bar has the correct valuereturn$cat->baz($bar,...);}}

Caution

In YAML you should put a space after { and before } (e.g. { _controller: ... }),
but this should not be done in Twig (e.g. {'hello' : 'value'}).

Section titles: use a variant of the title case, where the first
word is always capitalized and all other words are capitalized, except for
the closed-class words (read Wikipedia article about headings and titles).