SlideShare a Scribd company logo
Symfony Web Framework
Best Practices
Tigran Azatyan
2016 - From official documentation
1
2
Use the Symfony Installer to create new
Symfony-based projects.
3
Create only one bundle called AppBundle
for your application logic.
4
Define the infrastructure-related configuration options
in the app/config/parameters.yml file.
5
Define all your application's parameters in the
app/config/parameters.yml.dist file.
6
Define the application behavior related configuration
options in the app/config/config.yml file.
7
Use constants to define configuration options
that rarely change.
8
Don't define a semantic dependency injection
configuration for your bundles.
9
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.
10
Use the YAML format to define your own services.
11
Don't define parameters for the classes of your services.
12
Use annotations to define the mapping information
of the Doctrine entities.
13
Make your controller extend the FrameworkBundle
base controller and use annotations to configure
routing, caching and security whenever possible.
14
Don't use the @Template annotation to configure
the template used by the controller.
15
Use the ParamConverter trick to automatically
query for Doctrine entities
when it's simple and convenient.
16
Use Twig templating format for your templates.
17
Store all your application's templates in
app/Resources/views/ directory
18
Use lowercased snake_case for directory
and template names.
19
Define your Twig extensions in the
AppBundle/Twig/ directory and configure
them using the app/config/services.yml file.
20
Define your forms as PHP classes.
21
Put the form type classes in the AppBundleForm
namespace, unless you use other custom form
classes like data transformers.
22
Add buttons in the templates, not in the form
classes or the controllers.
23
Use the XLIFF format for your translation files.
24
Store the translation files in the
app/Resources/translations/ directory.
25
Always use keys for translations
instead of content strings.
26
Unless you have two legitimately different
authentication systems and users
(e.g. form login for the main site and a token
system for your API only), we recommend
having only one firewall entry
with the anonymous key enabled.
27
Use the bcrypt encoder for encoding
your users' passwords.
28
For protecting broad URL patterns,
use access_control;
Whenever possible, use the @Security annotation;
Check security directly on the
security.authorization_checker service
whenever you have a more complex situation.
29
For fine-grained restrictions, define a
custom security voter;
For restricting access to any object by any
user via an admin interface,
use the Symfony ACL.
30
Store your assets in the web/ directory.
31
Use Assetic to compile, combine and
minimize web assets, unless you're comfortable
with frontend tools like GruntJS.
32
Define a functional test that at least checks
if your application pages are successfully loading.
33
Hardcode the URLs used in the functional
tests instead of using the URL generator.
34
Enjoy coding With Symfony !!!

More Related Content

What's hot (20)

ODP
Mule ctf
D.Rajesh Kumar
 
PPTX
Integration with Salesforce using Mule ESB
Sanjeet Pandey
 
PPTX
Flowsinmule 160517130818
ppts123456
 
PPT
Slack connector with in MULE
D.Rajesh Kumar
 
PPT
MULE-JAAS
D.Rajesh Kumar
 
PPT
Anypoint platform highlights
himajareddys
 
PDF
Web Programming - 3 Laravel Framework
AndiNurkholis1
 
PPTX
Microsoft azure integration
Son Nguyen
 
PPTX
Telling the world why we love mule soft!
Sudha Ch
 
PPTX
Mule
F K
 
PPTX
Mule api gateway overview
Sanjeet Pandey
 
PPTX
Mule integration with Servicenow
Ramakrishna Narkedamilli
 
PPTX
Owin and-katana-overview
sonia merchant
 
PPT
Mule security-jaas
Praneethchampion
 
PDF
Designing keyword and Data Driven Automation framework with Selenium
Edureka!
 
PPTX
Mule groovy
Sindhu VL
 
PPTX
Anypoint b2 b
Achyuta Lakshmi
 
PPTX
Automatic documentation with mule
F K
 
PPTX
WatchOS Architecture
Avinash Gautam
 
PPTX
Code model
teach4uin
 
Mule ctf
D.Rajesh Kumar
 
Integration with Salesforce using Mule ESB
Sanjeet Pandey
 
Flowsinmule 160517130818
ppts123456
 
Slack connector with in MULE
D.Rajesh Kumar
 
MULE-JAAS
D.Rajesh Kumar
 
Anypoint platform highlights
himajareddys
 
Web Programming - 3 Laravel Framework
AndiNurkholis1
 
Microsoft azure integration
Son Nguyen
 
Telling the world why we love mule soft!
Sudha Ch
 
Mule
F K
 
Mule api gateway overview
Sanjeet Pandey
 
Mule integration with Servicenow
Ramakrishna Narkedamilli
 
Owin and-katana-overview
sonia merchant
 
Mule security-jaas
Praneethchampion
 
Designing keyword and Data Driven Automation framework with Selenium
Edureka!
 
Mule groovy
Sindhu VL
 
Anypoint b2 b
Achyuta Lakshmi
 
Automatic documentation with mule
F K
 
WatchOS Architecture
Avinash Gautam
 
Code model
teach4uin
 

Viewers also liked (20)

PDF
Introduction to PHP
Bradley Holt
 
PDF
ORO Meetups - Symfony2 Worst Practices
Mihail Sulima
 
PDF
Symfony - Introduction
Piers Warmers
 
PDF
The Naked Bundle - Symfony Live London 2014
Matthias Noback
 
PDF
Kotlin Developer Starter in Android projects
Bartosz Kosarzycki
 
PDF
Working With The Symfony Admin Generator
John Cleveley
 
PDF
PHP, non lo stesso vecchio linguaggio
Massimiliano Arione
 
PDF
Gestione delle dipendenze con Composer
Massimiliano Arione
 
PDF
The road to php7
Giuseppe Luciano
 
PDF
A Practical Introduction to Symfony2
Kris Wallsmith
 
PDF
Introduzione pratica a Symfony
Eugenio Minardi
 
PDF
Symfony Guard Authentication: Fun with API Token, Social Login, JWT and more
Ryan Weaver
 
PDF
PHP 7 - benvenuto al futuro
Christopher Pecoraro
 
PDF
30 Symfony Best Practices
Nicolas Perriault
 
PDF
Git-flow workflow and pull-requests
Bartosz Kosarzycki
 
PDF
From * to Symfony2
Manuel Baldassarri
 
PDF
Symfony2: 30 astuces et bonnes pratiques
Noel GUILBERT
 
PPTX
Service approach for development Rest API in Symfony2
Sumy PHP User Grpoup
 
PDF
Symfony: Your Next Microframework (SymfonyCon 2015)
Ryan Weaver
 
ODP
Symfony Best Practices
Baptiste Donaux
 
Introduction to PHP
Bradley Holt
 
ORO Meetups - Symfony2 Worst Practices
Mihail Sulima
 
Symfony - Introduction
Piers Warmers
 
The Naked Bundle - Symfony Live London 2014
Matthias Noback
 
Kotlin Developer Starter in Android projects
Bartosz Kosarzycki
 
Working With The Symfony Admin Generator
John Cleveley
 
PHP, non lo stesso vecchio linguaggio
Massimiliano Arione
 
Gestione delle dipendenze con Composer
Massimiliano Arione
 
The road to php7
Giuseppe Luciano
 
A Practical Introduction to Symfony2
Kris Wallsmith
 
Introduzione pratica a Symfony
Eugenio Minardi
 
Symfony Guard Authentication: Fun with API Token, Social Login, JWT and more
Ryan Weaver
 
PHP 7 - benvenuto al futuro
Christopher Pecoraro
 
30 Symfony Best Practices
Nicolas Perriault
 
Git-flow workflow and pull-requests
Bartosz Kosarzycki
 
From * to Symfony2
Manuel Baldassarri
 
Symfony2: 30 astuces et bonnes pratiques
Noel GUILBERT
 
Service approach for development Rest API in Symfony2
Sumy PHP User Grpoup
 
Symfony: Your Next Microframework (SymfonyCon 2015)
Ryan Weaver
 
Symfony Best Practices
Baptiste Donaux
 
Ad

Similar to Symfony Best Practices (20)

PDF
Some tips to improve developer experience with Symfony
tyomo4ka
 
PPTX
Building A Platform From Open Source At Yahoo
Dustin Whittle
 
PPT
Workshop: Symfony2 Intruduction: (Controller, Routing, Model)
Antonio Peric-Mazar
 
PDF
C:\fake path\askeet 1.0-en
univalle
 
PDF
Hands-on with the Symfony2 Framework
Ryan Weaver
 
PDF
Symfony quick tour_2.3
Frédéric Delorme
 
PDF
symfony: An Open-Source Framework for Professionals (Dutch Php Conference 2008)
Fabien Potencier
 
PDF
Myphp-busters: symfony framework
Stefan Koopmanschap
 
PDF
Symfony2 San Francisco Meetup 2009
Fabien Potencier
 
PPT
Plugins And Making Your Own
Lambert Beekhuis
 
PDF
Symfony 4: A new way to develop applications #ipc19
Antonio Peric-Mazar
 
PPTX
Freelance symfony framework
anikanielsen
 
ODP
Running Symfony
Wildan Maulana
 
ODP
An introduction to Symfony 2 for symfony 1 developers
Giorgio Cefaro
 
PPTX
SymfonyCon 2015 - A symphony of developers
Radu Murzea
 
PDF
Osiąganie mądrej architektury z Symfony2
3camp
 
PDF
Improve your web and app development with the Symfony3 framework.
Polcode
 
PDF
When e-commerce meets Symfony
Marc Morera
 
PDF
Symfony demonstration
Stephen McAuley
 
PDF
The Naked Bundle - Tryout
Matthias Noback
 
Some tips to improve developer experience with Symfony
tyomo4ka
 
Building A Platform From Open Source At Yahoo
Dustin Whittle
 
Workshop: Symfony2 Intruduction: (Controller, Routing, Model)
Antonio Peric-Mazar
 
C:\fake path\askeet 1.0-en
univalle
 
Hands-on with the Symfony2 Framework
Ryan Weaver
 
Symfony quick tour_2.3
Frédéric Delorme
 
symfony: An Open-Source Framework for Professionals (Dutch Php Conference 2008)
Fabien Potencier
 
Myphp-busters: symfony framework
Stefan Koopmanschap
 
Symfony2 San Francisco Meetup 2009
Fabien Potencier
 
Plugins And Making Your Own
Lambert Beekhuis
 
Symfony 4: A new way to develop applications #ipc19
Antonio Peric-Mazar
 
Freelance symfony framework
anikanielsen
 
Running Symfony
Wildan Maulana
 
An introduction to Symfony 2 for symfony 1 developers
Giorgio Cefaro
 
SymfonyCon 2015 - A symphony of developers
Radu Murzea
 
Osiąganie mądrej architektury z Symfony2
3camp
 
Improve your web and app development with the Symfony3 framework.
Polcode
 
When e-commerce meets Symfony
Marc Morera
 
Symfony demonstration
Stephen McAuley
 
The Naked Bundle - Tryout
Matthias Noback
 
Ad

Recently uploaded (20)

PDF
Meetup Kickoff & Welcome - Rohit Yadav, CSIUG Chairman
ShapeBlue
 
PPTX
UiPath Academic Alliance Educator Panels: Session 2 - Business Analyst Content
DianaGray10
 
PDF
Persuasive AI: risks and opportunities in the age of digital debate
Speck&Tech
 
PPTX
WooCommerce Workshop: Bring Your Laptop
Laura Hartwig
 
PPTX
Top Managed Service Providers in Los Angeles
Captain IT
 
PDF
CIFDAQ Token Spotlight for 9th July 2025
CIFDAQ
 
PDF
NewMind AI Journal - Weekly Chronicles - July'25 Week II
NewMind AI
 
PDF
Windsurf Meetup Ottawa 2025-07-12 - Planning Mode at Reliza.pdf
Pavel Shukhman
 
PPTX
✨Unleashing Collaboration: Salesforce Channels & Community Power in Patna!✨
SanjeetMishra29
 
PDF
NewMind AI - Journal 100 Insights After The 100th Issue
NewMind AI
 
PDF
DevBcn - Building 10x Organizations Using Modern Productivity Metrics
Justin Reock
 
PPTX
Building a Production-Ready Barts Health Secure Data Environment Tooling, Acc...
Barts Health
 
PDF
Chris Elwell Woburn, MA - Passionate About IT Innovation
Chris Elwell Woburn, MA
 
PPTX
Darren Mills The Migration Modernization Balancing Act: Navigating Risks and...
AWS Chicago
 
PDF
Human-centred design in online workplace learning and relationship to engagem...
Tracy Tang
 
PDF
July Patch Tuesday
Ivanti
 
PDF
Building Real-Time Digital Twins with IBM Maximo & ArcGIS Indoors
Safe Software
 
PDF
Wojciech Ciemski for Top Cyber News MAGAZINE. June 2025
Dr. Ludmila Morozova-Buss
 
PDF
LLMs.txt: Easily Control How AI Crawls Your Site
Keploy
 
PPTX
MSP360 Backup Scheduling and Retention Best Practices.pptx
MSP360
 
Meetup Kickoff & Welcome - Rohit Yadav, CSIUG Chairman
ShapeBlue
 
UiPath Academic Alliance Educator Panels: Session 2 - Business Analyst Content
DianaGray10
 
Persuasive AI: risks and opportunities in the age of digital debate
Speck&Tech
 
WooCommerce Workshop: Bring Your Laptop
Laura Hartwig
 
Top Managed Service Providers in Los Angeles
Captain IT
 
CIFDAQ Token Spotlight for 9th July 2025
CIFDAQ
 
NewMind AI Journal - Weekly Chronicles - July'25 Week II
NewMind AI
 
Windsurf Meetup Ottawa 2025-07-12 - Planning Mode at Reliza.pdf
Pavel Shukhman
 
✨Unleashing Collaboration: Salesforce Channels & Community Power in Patna!✨
SanjeetMishra29
 
NewMind AI - Journal 100 Insights After The 100th Issue
NewMind AI
 
DevBcn - Building 10x Organizations Using Modern Productivity Metrics
Justin Reock
 
Building a Production-Ready Barts Health Secure Data Environment Tooling, Acc...
Barts Health
 
Chris Elwell Woburn, MA - Passionate About IT Innovation
Chris Elwell Woburn, MA
 
Darren Mills The Migration Modernization Balancing Act: Navigating Risks and...
AWS Chicago
 
Human-centred design in online workplace learning and relationship to engagem...
Tracy Tang
 
July Patch Tuesday
Ivanti
 
Building Real-Time Digital Twins with IBM Maximo & ArcGIS Indoors
Safe Software
 
Wojciech Ciemski for Top Cyber News MAGAZINE. June 2025
Dr. Ludmila Morozova-Buss
 
LLMs.txt: Easily Control How AI Crawls Your Site
Keploy
 
MSP360 Backup Scheduling and Retention Best Practices.pptx
MSP360
 

Symfony Best Practices