Lock in $30 Savings on PRO—Offer Ends Soon! ⏳
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
200
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
58
Sustainable open source contributions in your business (CakeFest 2024)
skoop
0
91
Domain-Driven Design: The Basics (SymfonyCon 2023, Brussels)
skoop
0
210
Domain-Driven Design: The Basics (Cakefest)
skoop
0
220
PHP Kitchen Nightmares
skoop
0
59
Domain Driven Design - The Basics (TechTuesday XXL, Tilburg)
skoop
0
97
7 Lessons You Can Learn From Disney Movies (SymfonyCon 2022)
skoop
0
280
Mental Health in the Workplace (SymfonyCon 2019, Amsterdam)
skoop
0
700
Mental Health in the Workplace (PHPugle)
skoop
0
72
Other Decks in Technology
See All in Technology
20251127 BigQueryリモート関数で作る、お手軽AIバッチ実行環境
daimatz
0
390
ページの可視領域を算出する方法について整理する
yamatai1212
0
140
AI 時代のデータ戦略
na0
8
2.6k
Contract One Engineering Unit 紹介資料
sansan33
PRO
0
9.8k
Capture Checking / Separation Checking 入門
tanishiking
0
110
研究開発部メンバーの働き⽅ / Sansan R&D Profile
sansan33
PRO
3
21k
Excelデータ分析で学ぶディメンショナルモデリング ~アジャイルデータモデリングへ向けて~ by @Kazaneya_PR / 20251126
kazaneya
PRO
3
750
ブラウザ拡張のセキュリティの話 / Browser Extension Security
flatt_security
0
230
名刺メーカーDevグループ 紹介資料
sansan33
PRO
0
970
Symfony AI in Action
el_stoffel
2
280
2025 DORA Reportから読み解く!AIが映し出す、成果を出し続ける組織の共通点 #開発生産性_findy
takabow
2
900
AI エージェント活用のベストプラクティスと今後の課題
asei
2
420
Featured
See All Featured
Building Applications with DynamoDB
mza
96
6.8k
Rails Girls Zürich Keynote
gr2m
95
14k
The MySQL Ecosystem @ GitHub 2015
samlambert
251
13k
GraphQLの誤解/rethinking-graphql
sonatard
73
11k
Exploring the Power of Turbo Streams & Action Cable | RailsConf2023
kevinliebholz
36
6.1k
How GitHub (no longer) Works
holman
316
140k
How to Ace a Technical Interview
jacobian
280
24k
RailsConf 2023
tenderlove
30
1.3k
Building a Scalable Design System with Sketch
lauravandoore
463
34k
Scaling GitHub
holman
464
140k
Save Time (by Creating Custom Rails Generators)
garrettdimon
PRO
32
1.8k
How to Create Impact in a Changing Tech Landscape [PerfNow 2023]
tammyeverts
55
3.1k
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