Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Symfony3 Best Practices from the trenches
Search
Stefan Koopmanschap
May 24, 2016
Technology
1
190
Symfony3 Best Practices from the trenches
As done at PHP.FRL meetup in Heerenveen
Stefan Koopmanschap
May 24, 2016
Tweet
Share
More Decks by Stefan Koopmanschap
See All by Stefan Koopmanschap
PHP Kitchen Nightmares (PHP.FRL)
skoop
0
28
Sustainable open source contributions in your business (CakeFest 2024)
skoop
0
74
Domain-Driven Design: The Basics (SymfonyCon 2023, Brussels)
skoop
0
190
Domain-Driven Design: The Basics (Cakefest)
skoop
0
190
PHP Kitchen Nightmares
skoop
0
44
Domain Driven Design - The Basics (TechTuesday XXL, Tilburg)
skoop
0
90
7 Lessons You Can Learn From Disney Movies (SymfonyCon 2022)
skoop
0
260
Mental Health in the Workplace (SymfonyCon 2019, Amsterdam)
skoop
0
680
Mental Health in the Workplace (PHPugle)
skoop
0
61
Other Decks in Technology
See All in Technology
20250413_湘南kaggler会_音声認識で使うのってメルス・・・なんだっけ?
sugupoko
1
440
Lakeflow Connectのご紹介
databricksjapan
0
100
Amebaにおける Platform Engineeringの実践
kumorn5s
6
920
AI AgentOps LT大会(2025/04/16) Algomatic伊藤発表資料
kosukeito
0
130
SDカードフォレンジック
su3158
1
560
DuckDB MCPサーバーを使ってAWSコストを分析させてみた / AWS cost analysis with DuckDB MCP server
masahirokawahara
0
1.1k
Automatically generating types by running tests
sinsoku
2
660
古き良き Laravel のシステムは関数型スタイルでリファクタできるのか
leveragestech
1
650
MCP Documentation Server @AI Coding Meetup #1
yyoshiki41
2
2.6k
フロントエンドも盛り上げたい!フロントエンドCBとAmplifyの軌跡
mkdev10
2
260
All You Need Is Kusa 〜Slackデータで始めるデータドリブン〜
jonnojun
0
150
Classmethod AI Talks(CATs) #21 司会進行スライド(2025.04.17) / classmethod-ai-talks-aka-cats_moderator-slides_vol21_2025-04-17
shinyaa31
0
530
Featured
See All Featured
Making Projects Easy
brettharned
116
6.1k
The MySQL Ecosystem @ GitHub 2015
samlambert
251
12k
The Cost Of JavaScript in 2023
addyosmani
49
7.7k
Keith and Marios Guide to Fast Websites
keithpitt
411
22k
YesSQL, Process and Tooling at Scale
rocio
172
14k
Optimising Largest Contentful Paint
csswizardry
36
3.2k
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
29
9.4k
Practical Orchestrator
shlominoach
186
10k
Documentation Writing (for coders)
carmenintech
69
4.7k
Mobile First: as difficult as doing things right
swwweet
223
9.6k
XXLCSS - How to scale CSS and keep your sanity
sugarenia
248
1.3M
Imperfection Machines: The Place of Print at Facebook
scottboms
267
13k
Transcript
None
About me » PHPBenelux » PFZ » PHPAmersfoort/PHP.FRL » Ingewikkeld
» phpBB, Zend Framework, Symfony and many more
Once upon a time...
None
Dependency Injection
Dependency Injection » No hardcoded dependencies » Easily manage and
update specific classes » Program to contracts, not implementations » Minimize bootstrap code » More testable code
Dependency Injection class Foo { public function bar() { $coffee
= new Coffee(); $coffee->init(); return $coffee->drink(); } }
Dependency Injection $coffee = new Coffee();
Dependency Injection $coffee->init();
Dependency Injection class Coffee implements Roastable {} class Foo {
private $coffee; public function __construct(Roastable $coffee) { $this->coffee = $coffee; } }
Dependency Injection public function bar() { return $this->coffee->drink(); }
Dependency Injection parameters: coffee.class: "Coffee" foo.class: "Foo" services: coffee: class:
"%coffee.class%" foo: class: "%foo.class%" arguments: - "@coffee"
Dependency Injection class DefaultController { public function fooAction() { $foo
= $this->container->get('foo'); $foo->bar(); } }
Dependency Injection class DefaultController { private $foo; public function __construct(Foo
$foo) { $this->foo = $foo; } public function fooAction() { $this->foo->bar(); } }
Service layer Or: How Symfony is only implementation
Service layer » Seperation of concerns » Business logic should
not be bound to the application » Service layer can be accessed through the service container
Service layer public function showAction($productId) { $product = $this->getDoctrine() ->getRepository('AppBundle:Product')
->find($productId); if (!$product) { throw $this->createNotFoundException( 'No product found for id '.$productId ); } // ... do something, like pass the $product object into a template }
None
None
Service Layer Hexagonal architecture » http://php-and-symfony.matthiasnoback.nl/tags/ hexagonal%20architecture/ » http://protalk.me/the-framework-as-an- implementation-detail
None
Documentation
Documentation » The best starting point for your search »
Not the ultimate source for information
Documentation » Google » Stack Overflow » Blogs » IRC
Documentation » Something missing? Add it yourself! » https://github.com/symfony/symfony-docs
Documentation » Symfony Rainbow Series by Joshua Thijssen » https://leanpub.com/b/symfonyrainbowseries
Project Configuration
Project Configuration Everything in its right place » config*.yml »
routing*.yml » security.yml » parameters.yml
None
Project Configuration XML vs yaml » http://gowat.ch/xmlyml » http://converter.rosstuck.com/
Choose and Standardize
Choose » You can do things in multiple ways »
THIS IS GREAT! » Clarity, readability, maintainability
Standardize » Configuration: yml, xml, annotations » Controller extends or
not? » Naming of services, parameters, bundles
Ready for action?
Ready for action? » Use bundles correctly » Maximize external
library usage » Avoid |raw » .gitignore your parameters.yml » Translate! » Log all the things! » Stay up-to-date
Up-to-date » 2.7 - support until 05/2018, EOL 05/2019 »
2.8 - support until 11/2018, EOL 11/2019 » 3.0 - support until 07/2016, EOL 01/2017 » Next LTS: 3.4: support until 11/2020, EOL 11/2021
Questions?
I Salute You
I Salute You @skoop leftontheweb.com php.ingewikkeld.net