Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mention @Security() annotation instead of @Secure() #4733

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
1573 commits
Select commit Hold shift + click to select a range
ab66a12
Fix markup
wouterj Jan 9, 2015
528aa17
[Cookbook][Security] Hint about createToken can return null
xelaris Jan 9, 2015
0a60deb
[Cookbook][Routing] Fixed typo
xelaris Jan 9, 2015
7f8b051
Changed email message instantiation to a more 'symfonysh' way.
alebo Jan 10, 2015
68f36e3
[Book][Security] add back old anchors
xabbuh Jan 6, 2015
493e7a9
remove @Security annotation for Symfony 2.3
xabbuh Jan 2, 2015
c5d4ce1
bump required PHPUnit version
xabbuh Jan 2, 2015
93bc1bf
Update translation.rst
ifdattic Jan 13, 2015
49971fb
Use path to be consistent
wouterj Jan 13, 2015
83be144
Removed a leftover comma in security config sample
javiereguiluz Jan 13, 2015
3a7d0f4
Fixed typo
SofHad Jan 13, 2015
cc7853d
Fixed 404 page
SofHad Jan 13, 2015
c8a8b10
Fixed 404 page
SofHad Jan 13, 2015
7970f76
Fix code example
ifdattic Jan 14, 2015
cc5564e
Update override.rst
ifdattic Jan 14, 2015
44b1584
Update override.rst
ifdattic Jan 14, 2015
05d1a64
Fixed broken link #4827
SofHad Jan 14, 2015
73f07ed
Fixed typo
beni0888 Jan 15, 2015
d83f005
Fix typo: BLOG => BLOB
ifdattic Jan 16, 2015
32a589b
[Components][Debug] fix DebugClassLoader namespace
xabbuh Jan 16, 2015
bd7d246
minor #4752 [Book][Validation] clarify group validation (xabbuh)
wouterj Jan 16, 2015
1b31ad1
Add custom link labels where Cookbook articles titles looked wrong
javiereguiluz Jan 16, 2015
a42e5b6
minor #4778 Update templating.rst (ifdattic)
wouterj Jan 16, 2015
6522145
minor #4799 Fix markup (WouterJ)
wouterj Jan 16, 2015
f7d99dd
[#4799] One little fix more
wouterj Jan 16, 2015
e913808
minor #4802 [Cookbook][Routing] Fixed typo (xelaris)
wouterj Jan 16, 2015
44277c7
don't output message from AuthenticationException
xabbuh Jan 4, 2015
892586b
minor #4808 Email message instantiation changed to a more 'symfonysh'…
wouterj Jan 16, 2015
82bce29
minor #4815 Update translation.rst (ifdattic)
wouterj Jan 16, 2015
f7179df
minor #4818 [Routing] Removed deprecated usage (WouterJ)
wouterj Jan 16, 2015
91a89b7
minor #4821 Fixed typo (SofHad)
wouterj Jan 16, 2015
ecc18e2
fix SQL: table names
e-moe Jan 13, 2015
467c538
minor #4824 fix SQL: table names (e-moe)
wouterj Jan 16, 2015
f34fc2d
minor #4825 Fixed the 404 not found error (SofHad)
wouterj Jan 16, 2015
d2a67ac
minor #4826 Fixed 404 page (SofHad)
wouterj Jan 16, 2015
13ffb83
minor #4835 Fixed broken link (SofHad)
wouterj Jan 16, 2015
5b91653
minor #4843 Fixed typo (beni0888)
wouterj Jan 16, 2015
449ee9a
Fixed typo
beni0888 Jan 15, 2015
c243d00
minor #4843 Fixed typo (beni0888)
wouterj Jan 16, 2015
952e317
Merge branch '2.3' into 2.5
wouterj Jan 16, 2015
1da9206
Merge branch '2.5' into 2.6
wouterj Jan 16, 2015
313c1b9
Update routing.rst
bglamer Jan 15, 2015
9680ec0
minor #4844 Update routing.rst (bglamer)
wouterj Jan 16, 2015
70d5aba
Update security.rst
Jan 16, 2015
f9c1389
minor #4845 Update security.rst (meelijane)
wouterj Jan 16, 2015
c04ed79
minor #4848 Fix typo: BLOG => BLOB (ifdattic)
wouterj Jan 16, 2015
a23e7d2
feature #4643 How to override vendor directory location (gajdaw)
weaverryan Jan 16, 2015
839c9ef
replace API link for SwiftmailerBundle
xabbuh Jan 16, 2015
77d98a6
[#4643] Minor english changes to make things even smoother (though th…
weaverryan Jan 16, 2015
0f4fda7
Adding an example image of the debug_formatter
weaverryan Dec 16, 2014
9e4eb5a
language tweak thanks to xabbuh!
weaverryan Jan 16, 2015
cc40b5c
Adding missing words thanks to javiereguiluz
weaverryan Jan 16, 2015
11b9d23
minor #4772 Tweaks to the new form csrf caching entry (weaverryan)
weaverryan Jan 16, 2015
e347ec8
minor #4819 Removed a leftover comma in security config sample (javie…
wouterj Jan 16, 2015
84839ba
minor #4829 Fix code example (ifdattic)
wouterj Jan 16, 2015
36d1bac
Fixing bad english thanks to xabbuh
weaverryan Jan 16, 2015
7a6f30e
Merge remote-tracking branch 'origin/2.3' into 2.3
weaverryan Jan 16, 2015
17989fd
minor #4860 [Components][HttpKernel] replace API link for Swiftmailer…
wouterj Jan 16, 2015
e9559a5
move cautions to make them visible
xabbuh Jan 4, 2015
c454fd2
minor #4857 Add custom link labels where Cookbook articles titles loo…
weaverryan Jan 16, 2015
11c1047
[#4857] Adding missing word thanks to xabbuh
weaverryan Jan 16, 2015
9742b92
feature #4761 [Cookbook][Security] don't output message from Authenti…
weaverryan Jan 16, 2015
3a25b1d
Merge branch '2.3' into 2.5
weaverryan Jan 16, 2015
4b0ebea
Merge branch '2.5' into 2.6
weaverryan Jan 16, 2015
3643ec2
feature #4723 [Cookbook][Security] document the new AuthenticationUti…
weaverryan Jan 16, 2015
657284e
Adding a link to log things in the prod environment
weaverryan Dec 7, 2014
2b73801
Typo Fix: "allows to" should be "allows you to"
mattjanssen Jan 14, 2015
4f47dec
minor #4837 Monolog Cookbook Typo Fix: "allows to" should be "allows …
weaverryan Jan 16, 2015
cfad26c
feature #4605 Adding a link to log things in the prod environment (we…
weaverryan Jan 16, 2015
08e5ac9
feature #4658 Debug formatter tweaks (weaverryan)
weaverryan Jan 16, 2015
cf3d38a
minor #4731 [Book][Testing] bump required PHPUnit version (xabbuh)
weaverryan Jan 16, 2015
5940d52
bug #4735 [BestPractices] remove @Security annotation for Symfony 2.3…
weaverryan Jan 16, 2015
9a6f242
Merge branch '2.3' into 2.5
weaverryan Jan 16, 2015
2fe954e
[#4735] Reverting what was left on the 2.5 branch after the merge con…
weaverryan Jan 16, 2015
528e8e1
feature #4740 Use AppBundle whenever it's possible (javiereguiluz)
weaverryan Jan 16, 2015
7a8e00d
Merge branch '2.3' into 2.5
weaverryan Jan 16, 2015
9fee9ee
bug #4746 Revert #4651 for 2.3 branch (xelaris)
weaverryan Jan 16, 2015
c8928d8
Merge branch '2.3' into 2.5
weaverryan Jan 16, 2015
50946ca
Reverting a commit on 2.5 branch, as it was only meant to be on 2.3 (…
weaverryan Jan 16, 2015
240a981
minor #4764 [Reference][Forms] move cautions to make them visible (xa…
weaverryan Jan 16, 2015
48835de
minor #4767 [2.6] Removed 2.4 versionadded as version is deprecated (…
weaverryan Jan 16, 2015
a6a3b9c
Update inheritance.rst
ifdattic Jan 14, 2015
b4ee5fb
Update security.rst
ifdattic Jan 10, 2015
0d059ff
Update http_cache.rst
ifdattic Jan 11, 2015
8b6cd17
Update testing.rst
ifdattic Jan 12, 2015
4eb8b64
Update doctrine.rst
ifdattic Jan 13, 2015
76b23af
Update translation.rst
ifdattic Jan 13, 2015
04ae7c2
Update configuration.rst
ifdattic Jan 14, 2015
8d9a47c
Update prepend_extension.rst
ifdattic Jan 14, 2015
ff9f315
Update asset_management.rst
ifdattic Jan 15, 2015
7c9c7ad
Update apply_to_option.rst
ifdattic Jan 15, 2015
07aefea
Update error_pages.rst
ifdattic Jan 15, 2015
80fc665
Update configuration_organization.rst
ifdattic Jan 16, 2015
ece3904
Update environments.rst
ifdattic Jan 16, 2015
5e7846e
Update spool.rst
ifdattic Jan 16, 2015
2980cad
Update cloud.rst
ifdattic Jan 16, 2015
a2e0a27
Update gmail.rst
ifdattic Jan 16, 2015
7f600ef
Remove horizontal scrollbar
ifdattic Jan 17, 2015
5c55491
fix merge after removing @Security in 2.3
xabbuh Jan 17, 2015
b8ed4b7
[BestPractices] fix minor typo
xabbuh Jan 17, 2015
98bd7ba
Remove trailing whitespace
wouterj Jan 17, 2015
dc2829c
[varnish] be more precise about version differences
dbu Jan 9, 2015
e825333
Remove horizontal scrollbar
ifdattic Jan 18, 2015
c88ad32
explain how to work with cookies and sessions when caching
dbu Dec 11, 2014
7a4dafc
remove part about vary on cookie
dbu Dec 31, 2014
b294b24
cleanup from feedback
dbu Jan 1, 2015
acb5868
[Book][Translation] Added tip for routing params
xelaris Jan 9, 2015
dbbe9de
[Book][Security] Remove out-dated anchor
xelaris Jan 18, 2015
4143076
minor #4872 [BestPractices] fix merge after removing @Security in 2.3…
weaverryan Jan 18, 2015
0615928
Merge branch '2.5' into 2.6
weaverryan Jan 18, 2015
c4c8803
Update introduction.rst
quberok Jan 19, 2015
960b438
Remove horizontal scrollbar
ifdattic Jan 19, 2015
4121dbd
[VarDumper] add a tip about global dump() availability
nicolas-grekas Jan 19, 2015
bcf1508
minor #4785 [Book][Security] add back old anchors (xabbuh)
weaverryan Jan 19, 2015
73ff5ea
restore the how to NOT do it example in the "Service: No Class Parame…
uvoelkel Jan 20, 2015
9edffa0
Typo
Jan 20, 2015
0a678d2
fixed indentation
uvoelkel Jan 20, 2015
f1f3c50
Fixed typo
beni0888 Jan 20, 2015
aaecb02
Move annotations example to front
ifdattic Jan 21, 2015
a61ffba
Align methods in YAML example
ifdattic Jan 21, 2015
65b0822
minor #4798 Add version added note for the debug:event-dispatcher com…
weaverryan Jan 21, 2015
572bf3b
feature #4800 [Cookbook][Security] Hint about createToken can return …
weaverryan Jan 21, 2015
3293286
feature #4801 [Cookbook][cache][varnish] be more precise about versio…
weaverryan Jan 21, 2015
ac60187
Fix typo: looks => look
ifdattic Jan 22, 2015
42269d4
Removed the Stable API chapter from the Symfony book
javiereguiluz Jan 23, 2015
4d472c2
Added a reference about including JS and CSS files in PHP templates
javiereguiluz Jan 23, 2015
5c6d4b2
Fixed a minor RST syntax issue
javiereguiluz Jan 23, 2015
cf48e1a
Update routing.rst
IlhamiD Jan 23, 2015
b9359a2
bug #4905 Update routing.rst (IlhamiD)
wouterj Jan 23, 2015
6f1bbab
Merge branch '2.3' into 2.5
wouterj Jan 23, 2015
65da1a9
Merge branch '2.5' into 2.6
wouterj Jan 23, 2015
8ef3477
bug #4856 [Components][Debug] fix DebugClassLoader namespace (xabbuh)
wouterj Jan 23, 2015
f361c87
Removed literals for bundle names
wouterj Jan 16, 2015
6cffa4e
minor #4866 Remove horizontal scrollbar (ifdattic)
wouterj Jan 23, 2015
80bef5a
minor #4873 [BestPractices] fix minor typo (xabbuh)
wouterj Jan 23, 2015
6a15077
minor #4874 Remove trailing whitespace (WouterJ)
wouterj Jan 23, 2015
d85fa76
minor #4880 Remove duplicate link, introduction.rst (Quberik)
wouterj Jan 23, 2015
f76ff18
Remove 'acme'
ifdattic Jan 19, 2015
3774a37
minor #4881 Remove 'acme' (ifdattic)
wouterj Jan 23, 2015
2f41c9e
minor #4887 Typo (XitasoChris)
wouterj Jan 23, 2015
8ea0fef
added Kévin as a merger for the Serializer component
fabpot Jan 22, 2015
b71b007
Set twig service as private
ifdattic Jan 24, 2015
430de15
don't explain deprecated `getName()` method
xabbuh Jan 16, 2015
d078ca4
Fix typo, remove horizontal scrollbar
ifdattic Jan 25, 2015
4d400bd
Fix typos
ifdattic Jan 25, 2015
7065dd1
Remove horizontal scrollbar
ifdattic Jan 25, 2015
f9c2d69
minor #4803 [Book][Translation] Added tip for routing params (xelaris)
weaverryan Jan 25, 2015
9a6d7b9
minor #4831 Update override.rst (ifdattic)
weaverryan Jan 25, 2015
62248df
Merge branch '2.3' into 2.5
weaverryan Jan 25, 2015
b0d2263
Merge branch '2.5' into 2.6
weaverryan Jan 25, 2015
299ead1
Quick proofread of the email cookbook
weaverryan Jan 25, 2015
33914c9
minor #4859 [Components][EventDispatcher] don't explain deprecated `g…
weaverryan Jan 25, 2015
a6b7d72
bug #4861 Ifdattic's fixes (ifdattic)
weaverryan Jan 25, 2015
f5f3c1b
minor #4865 Removed literals for bundle names (WouterJ)
weaverryan Jan 25, 2015
5207800
Adding reference link
weaverryan Jan 25, 2015
b624100
Fixing bad `@AcmeHello` -> `@AcmeHelloBundle`
weaverryan Jan 25, 2015
dc87147
minor #4876 Remove horizontal scrollbar (ifdattic)
weaverryan Jan 25, 2015
2f8a60e
Merge branch '2.3' into 2.5
weaverryan Jan 25, 2015
9ec09ee
Merge branch '2.5' into 2.6
weaverryan Jan 25, 2015
fe5d1eb
Fix typo: Fabien => World
ifdattic Jan 26, 2015
6cf38d3
Fix typo: missing space
ifdattic Jan 26, 2015
d1de1c8
Fix typo: missing of
ifdattic Jan 26, 2015
4343d96
Fix code examples
ifdattic Jan 26, 2015
26415e2
Remove block which doesn't make sense after best practices
ifdattic Jan 27, 2015
0c236b4
Remove horizontal scrollbar
ifdattic Jan 28, 2015
a21042c
Fix typo
ifdattic Jan 29, 2015
b04f311
Fix typos
ifdattic Jan 29, 2015
3f24f8e
Fix typo
ifdattic Jan 29, 2015
3fe41fd
Misc changes
ifdattic Jan 29, 2015
611a011
Fix typos
ifdattic Jan 29, 2015
3bb7b61
feature #4645 Remove note that's no longer the case (thewilkybarkid)
weaverryan Jan 30, 2015
4226fc2
feature #4883 Global dump (nicolas-grekas)
weaverryan Jan 30, 2015
7e84533
bug #4886 [Best Pracitices] restore example in the "Service: No Class…
weaverryan Jan 30, 2015
00981de
minor #4890 Fixed typo (beni0888)
weaverryan Jan 30, 2015
f84cdb6
fixed typo (acme -> app)
Jan 20, 2015
2b7e5ee
minor #4891 fixed typo (acme -> app) (adiebler)
weaverryan Jan 30, 2015
7c66a8b
minor #4893 Move annotations example to front (ifdattic)
weaverryan Jan 30, 2015
a6fb18c
Added configuration of the your_api_key_user_provider as user provider
peterrehm Jan 21, 2015
c4cbd84
Updated according to comment and changed to AppBundle
peterrehm Jan 23, 2015
56dd365
Updated as per discussion
peterrehm Jan 24, 2015
075b652
Removed unneeded spaces
peterrehm Jan 25, 2015
50c5a9e
feature #4895 Added configuration of the user provider (peterrehm)
weaverryan Jan 30, 2015
fbaeecd
minor #4898 added Kévin Dunglas as a merger for the Serializer compon…
weaverryan Jan 30, 2015
37fd035
minor #4899 Fix typo: looks => look (ifdattic)
weaverryan Jan 30, 2015
bd279f6
minor #4908 Set twig service as private (ifdattic)
weaverryan Jan 30, 2015
fc776ab
minor #4894 Align methods in YAML example (ifdattic)
weaverryan Jan 30, 2015
d7acccf
minor #4914 Fix typo, remove horizontal scrollbar (ifdattic)
weaverryan Jan 30, 2015
20d80c3
minor #4916 Fixes for 2.3 branch (ifdattic)
weaverryan Jan 30, 2015
d1103a8
minor #4919 Fix code examples (ifdattic)
weaverryan Jan 30, 2015
30ecdde
minor #4921 Fixes for 2.5 branch (ifdattic)
weaverryan Jan 30, 2015
418a73b
minor #4922 Fix typo: missing space (ifdattic)
weaverryan Jan 30, 2015
947e58b
Add missing comma in array
ifdattic Jan 28, 2015
768650e
minor #4932 Add missing comma in array (ifdattic)
weaverryan Jan 30, 2015
d32c51c
Fixing typo thanks to xabbuh
weaverryan Jan 30, 2015
3921d70
minor #4918 Quick proofread of the email cookbook (weaverryan)
weaverryan Jan 30, 2015
585644b
Merge branch '2.3' into 2.5
weaverryan Jan 30, 2015
ddf9aa5
Merge branch '2.5' into 2.6
weaverryan Jan 30, 2015
ad74169
feature #4628 Varnish cookbook session cookie handling (dbu)
weaverryan Jan 30, 2015
cd1dfa4
Fix typo: These => This
ifdattic Jan 30, 2015
4476646
Fix code example to be more readable
ifdattic Jan 30, 2015
c30f470
Keeping documentation consistent
thecatontheflat Jan 29, 2015
0fa9cbd
minor #4937 Keeping documentation consistent (thecatontheflat)
wouterj Jan 30, 2015
d17ca87
fixed typo
issei-m Jan 29, 2015
04090c0
minor #4936 fixed typo (issei-m)
wouterj Jan 30, 2015
b32accb
minor #4935 Fix typos (ifdattic)
wouterj Jan 30, 2015
b45dc3a
removed backup file
wouterj Jan 30, 2015
1503df6
Merge branch '2.3' into 2.5
wouterj Jan 30, 2015
eb86338
Merge branch '2.5' into 2.6
wouterj Jan 30, 2015
e2769ba
Update sessions.rst
ifdattic Jan 30, 2015
2aa40e6
Change installation method order
ifdattic Jan 31, 2015
17c9cf9
Remove horizontal scrollbar
ifdattic Jan 31, 2015
6b3b3bc
Fix typos
ifdattic Jan 31, 2015
5a53e87
minor #4946 Remove horizontal scrollbar (ifdattic)
wouterj Jan 31, 2015
137ba72
minor #4945 Fixes for 2.3 branch (ifdattic)
wouterj Jan 31, 2015
6572fea
Fix formatting
ifdattic Jan 30, 2015
3907af6
minor #4944 Fix formatting (ifdattic)
wouterj Jan 31, 2015
99d225b
minor #4943 Fixes for 2.3 branch (ifdattic)
wouterj Jan 31, 2015
83696b8
minor #4934 Fixes for 2.3 branch (ifdattic)
wouterj Jan 31, 2015
c24c787
minor #4931 Remove horizontal scrollbar (ifdattic)
wouterj Jan 31, 2015
e2efc6b
Fixed composer create-project command (windows)
Epskampie Nov 20, 2014
ea51aeb
bug #4926 Finish #4505: Fixed composer create-project command (window…
wouterj Jan 31, 2015
a97646f
minor #4882 Remove horizontal scrollbar (ifdattic)
wouterj Jan 31, 2015
2cff942
minor #4878 [Book][Security] Remove out-dated anchor (xelaris)
wouterj Jan 31, 2015
da70836
Fix typos
ifdattic Feb 1, 2015
6e023c1
Fix typos
ifdattic Feb 1, 2015
e6ffd5d
Add missing comma in array
ifdattic Feb 1, 2015
9ad21ea
Fix typos
ifdattic Feb 1, 2015
737692e
Merge branch '2.3' into 2.5
wouterj Feb 1, 2015
a49ffcc
Merge branch '2.5' into 2.6
wouterj Feb 1, 2015
21ca2ba
Added January changelog
wouterj Feb 1, 2015
3a86e3c
Merge branch '2.3' into 2.5
wouterj Feb 1, 2015
9606566
Added January changelog
wouterj Feb 1, 2015
fd0862b
Merge branch '2.5' into 2.6
wouterj Feb 1, 2015
851024b
Added January changelog
wouterj Feb 1, 2015
c5ce1de
Fix build error in changelog
wouterj Feb 1, 2015
6dd6735
Merge branch '2.3' into 2.5
wouterj Feb 1, 2015
35093fa
Merge branch '2.5' into 2.6
wouterj Feb 1, 2015
2305066
feature #4902 Removed the Stable API chapter from the Symfony book (j…
weaverryan Feb 1, 2015
6f8b145
minor #4904 Added a reference about including JS and CSS files in PHP…
weaverryan Feb 1, 2015
475be21
Change installation method order
ifdattic Jan 27, 2015
1db39c2
Update introduction.rst
ifdattic Jan 27, 2015
008c4de
minor #4928 Change installation method order (ifdattic)
weaverryan Feb 1, 2015
0afc689
[#4928] Backporting change after merging into 2.5 (since 2.3 is a lit…
weaverryan Feb 1, 2015
52e21f3
Merge branch '2.3' into 2.5
weaverryan Feb 1, 2015
42b44c4
minor #4929 Remove block which doesn't make sense after best practice…
weaverryan Feb 1, 2015
6be214c
minor #4948 Fixes for 2.6 branch (ifdattic)
weaverryan Feb 1, 2015
208904a
minor #4949 Fixes for 2.3 branch (ifdattic)
weaverryan Feb 1, 2015
169315b
Merge branch '2.3' into 2.5
weaverryan Feb 1, 2015
6ba90ec
Merge branch '2.5' into 2.6
weaverryan Feb 1, 2015
99163ed
Mention @Security() annotation instead of @Secure()
javiereguiluz Feb 3, 2015
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
6 changes: 0 additions & 6 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,8 +1,2 @@
/_build
/bundles/DoctrineFixturesBundle
/bundles/DoctrineMigrationsBundle
/bundles/DoctrineMongoDBBundle
/bundles/SensioFrameworkExtraBundle
/bundles/SensioGeneratorBundle
/cmf
/_exts
3 changes: 2 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ language: python
python:
- "2.7"

sudo: false

install:
- "bash install.sh"
- "pip install -q -r requirements.txt --use-mirrors"

script: sphinx-build -nW -b html -d _build/doctrees . _build/html
Expand Down
2 changes: 1 addition & 1 deletion _exts
341 changes: 341 additions & 0 deletions best_practices/business-logic.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,341 @@
Organizing Your Business Logic
==============================

In computer software, **business logic** or domain logic is "the part of the
program that encodes the real-world business rules that determine how data can
be created, displayed, stored, and changed" (read `full definition`_).

In Symfony applications, business logic is all the custom code you write for
your app that's not specific to the framework (e.g. routing and controllers).
Domain classes, Doctrine entities and regular PHP classes that are used as
services are good examples of business logic.

For most projects, you should store everything inside the AppBundle.
Inside here, you can create whatever directories you want to organize things:

.. code-block:: text

symfony2-project/
├─ app/
├─ src/
│ └─ AppBundle/
│ └─ Utils/
│ └─ MyClass.php
├─ vendor/
└─ web/

Storing Classes Outside of the Bundle?
--------------------------------------

But there's no technical reason for putting business logic inside of a bundle.
If you like, you can create your own namespace inside the ``src/`` directory
and put things there:

.. code-block:: text

symfony2-project/
├─ app/
├─ src/
│ ├─ Acme/
│ │ └─ Utils/
│ │ └─ MyClass.php
│ └─ AppBundle/
├─ vendor/
└─ web/

.. tip::

The recommended approach of using the ``AppBundle/`` directory is for
simplicity. If you're advanced enough to know what needs to live in
a bundle and what can live outside of one, then feel free to do that.

Services: Naming and Format
---------------------------

The blog application needs a utility that can transform a post title (e.g.
"Hello World") into a slug (e.g. "hello-world"). The slug will be used as
part of the post URL.

Let's, create a new ``Slugger`` class inside ``src/AppBundle/Utils/`` and
add the following ``slugify()`` method:

.. code-block:: php

// src/AppBundle/Utils/Slugger.php
namespace AppBundle\Utils;

class Slugger
{
public function slugify($string)
{
return preg_replace(
'/[^a-z0-9]/', '-', strtolower(trim(strip_tags($string)))
);
}
}

Next, define a new service for that class.

.. code-block:: yaml

# app/config/services.yml
services:
# keep your service names short
app.slugger:
class: AppBundle\Utils\Slugger

Traditionally, the naming convention for a service involved following the
class name and location to avoid name collisions. Thus, the service
*would have been* called ``app.utils.slugger``. But by using short service names,
your code will be easier to read and use.

.. best-practice::

The name of your application's services should be as short as possible,
but unique enough that you can search your project for the service if
you ever need to.

Now you can use the custom slugger in any controller class, such as the
``AdminController``:

.. code-block:: php

public function createAction(Request $request)
{
// ...

if ($form->isSubmitted() && $form->isValid()) {
$slug = $this->get('app.slugger')->slugify($post->getTitle());
$post->setSlug($slug);

// ...
}
}

Service Format: YAML
--------------------

In the previous section, YAML was used to define the service.

.. best-practice::

Use the YAML format to define your own services.

This is controversial, and in our experience, YAML and XML usage is evenly
distributed among developers, with a slight preference towards YAML.
Both formats have the same performance, so this is ultimately a matter of
personal taste.

We recommend YAML because it's friendly to newcomers and concise. You can
of course use whatever format you like.

Service: No Class Parameter
---------------------------

You may have noticed that the previous service definition doesn't configure
the class namespace as a parameter:

.. code-block:: yaml

# app/config/services.yml

# service definition with class namespace as parameter
parameters:
slugger.class: AppBundle\Utils\Slugger

services:
app.slugger:
class: "%slugger.class%"

This practice is cumbersome and completely unnecessary for your own services:

.. best-practice::

Don't define parameters for the classes of your services.

This practice was wrongly adopted from third-party bundles. When Symfony
introduced its service container, some developers used this technique to easily
allow overriding services. However, overriding a service by just changing its
class name is a very rare use case because, frequently, the new service has
different constructor arguments.

Using a Persistence Layer
-------------------------

Symfony is an HTTP framework that only cares about generating an HTTP response
for each HTTP request. That's why Symfony doesn't provide a way to talk to
a persistence layer (e.g. database, external API). You can choose whatever
library or strategy you want for this.

In practice, many Symfony applications rely on the independent
`Doctrine project`_ to define their model using entities and repositories.
Just like with business logic, we recommend storing Doctrine entities in the
AppBundle.

The three entities defined by our sample blog application are a good example:

.. code-block:: text

symfony2-project/
├─ ...
└─ src/
└─ AppBundle/
└─ Entity/
├─ Comment.php
├─ Post.php
└─ User.php

.. tip::

If you're more advanced, you can of course store them under your own
namespace in ``src/``.

Doctrine Mapping Information
~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Doctrine Entities are plain PHP objects that you store in some "database".
Doctrine only knows about your entities through the mapping metadata configured
for your model classes. Doctrine supports four metadata formats: YAML, XML,
PHP and annotations.

.. best-practice::

Use annotations to define the mapping information of the Doctrine entities.

Annotations are by far the most convenient and agile way of setting up and
looking for mapping information:

.. code-block:: php

namespace AppBundle\Entity;

use Doctrine\ORM\Mapping as ORM;
use Doctrine\Common\Collections\ArrayCollection;

/**
* @ORM\Entity
*/
class Post
{
const NUM_ITEMS = 10;

/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
private $id;

/**
* @ORM\Column(type="string")
*/
private $title;

/**
* @ORM\Column(type="string")
*/
private $slug;

/**
* @ORM\Column(type="text")
*/
private $content;

/**
* @ORM\Column(type="string")
*/
private $authorEmail;

/**
* @ORM\Column(type="datetime")
*/
private $publishedAt;

/**
* @ORM\OneToMany(
* targetEntity="Comment",
* mappedBy="post",
* orphanRemoval=true
* )
* @ORM\OrderBy({"publishedAt" = "ASC"})
*/
private $comments;

public function __construct()
{
$this->publishedAt = new \DateTime();
$this->comments = new ArrayCollection();
}

// getters and setters ...
}

All formats have the same performance, so this is once again ultimately a
matter of taste.

Data Fixtures
~~~~~~~~~~~~~

As fixtures support is not enabled by default in Symfony, you should execute
the following command to install the Doctrine fixtures bundle:

.. code-block:: bash

$ composer require "doctrine/doctrine-fixtures-bundle"

Then, enable the bundle in ``AppKernel.php``, but only for the ``dev`` and
``test`` environments:

.. code-block:: php

use Symfony\Component\HttpKernel\Kernel;

class AppKernel extends Kernel
{
public function registerBundles()
{
$bundles = array(
// ...
);

if (in_array($this->getEnvironment(), array('dev', 'test'))) {
// ...
$bundles[] = new Doctrine\Bundle\FixturesBundle\DoctrineFixturesBundle();
}

return $bundles;
}

// ...
}

We recommend creating just *one* `fixture class`_ for simplicity, though
you're welcome to have more if that class gets quite large.

Assuming you have at least one fixtures class and that the database access
is configured properly, you can load your fixtures by executing the following
command:

.. code-block:: bash

$ php app/console doctrine:fixtures:load

Careful, database will be purged. Do you want to continue Y/N ? Y
> purging database
> loading AppBundle\DataFixtures\ORM\LoadFixtures

Coding Standards
----------------

The Symfony source code follows the `PSR-1`_ and `PSR-2`_ coding standards that
were defined by the PHP community. You can learn more about
:doc:`the Symfony Coding standards </contributing/code/standards>` and even
use the `PHP-CS-Fixer`_, which is a command-line utility that can fix the
coding standards of an entire codebase in a matter of seconds.

.. _`full definition`: http://en.wikipedia.org/wiki/Business_logic
.. _`Doctrine project`: http://www.doctrine-project.org/
.. _`fixture class`: http://symfony.com/doc/current/bundles/DoctrineFixturesBundle/index.html#writing-simple-fixtures
.. _`PSR-1`: http://www.php-fig.org/psr/psr-1/
.. _`PSR-2`: http://www.php-fig.org/psr/psr-2/
.. _`PHP-CS-Fixer`: https://github.com/FriendsOfPHP/PHP-CS-Fixer
Loading