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
220
1
Share
Symfony3 Best Practices from the trenches
As done at PHP.FRL meetup in Heerenveen
Stefan Koopmanschap
May 24, 2016
More Decks by Stefan Koopmanschap
See All by Stefan Koopmanschap
How to make good decisions with a happy team (SymfonyCon 2025)
skoop
0
88
PHP Kitchen Nightmares (PHP.FRL)
skoop
0
100
Sustainable open source contributions in your business (CakeFest 2024)
skoop
0
120
Domain-Driven Design: The Basics (SymfonyCon 2023, Brussels)
skoop
0
240
Domain-Driven Design: The Basics (Cakefest)
skoop
0
260
PHP Kitchen Nightmares
skoop
0
80
Domain Driven Design - The Basics (TechTuesday XXL, Tilburg)
skoop
0
120
7 Lessons You Can Learn From Disney Movies (SymfonyCon 2022)
skoop
0
310
Mental Health in the Workplace (SymfonyCon 2019, Amsterdam)
skoop
0
740
Other Decks in Technology
See All in Technology
個人最適 から 全体最適 へ AI情報共有会・AIギルド・AI-DLC で進める カンリーの組織展開
rfdnxbro
0
1.4k
BigQuery の Cross-cloud Lakehouse への歩み
phaya72
2
540
AI Testing Talks: Challenges of Applying AI in Software Testing: From Hype to Practical Use
exactpro
PRO
1
110
「気づいたら仕事が終わっている」バクラクAIエージェント本番運用の裏側 / layerx-bakuraku-aie2026
yuya4
18
9.6k
DevOps Agentで始めるAWS運用 〜フロンティアエージェントが変える運用の現場〜
nyankotaro
1
120
速さだけじゃない! VoidZero ツールが移行先に選ばれる理由
mizdra
PRO
6
740
Chart.js が簡単に使えるようになっていたので OGP 画像生成に使った話
kamekyame
0
150
正解のないAIプロダクトをどう導くか?dodaが挑む、ユーザーの『本音』を構造化する評価設計と検証のリアル
techtekt
PRO
0
170
新規事業を牽引する技術選定 〜フルスタックTypeScript開発の実践事例〜
nullnull
2
300
GoとSIMDとWasmの今。
askua
3
490
AI フレンドリーなエラー監視を TypeScript で実現する
shinyaigeek
2
250
マーケットプレイス版Oracle WebCenter Content For OCI
oracle4engineer
PRO
5
1.8k
Featured
See All Featured
Skip the Path - Find Your Career Trail
mkilby
1
140
Embracing the Ebb and Flow
colly
88
5.1k
Game over? The fight for quality and originality in the time of robots
wayneb77
1
190
Raft: Consensus for Rubyists
vanstee
141
7.5k
Unsuck your backbone
ammeep
672
58k
B2B Lead Gen: Tactics, Traps & Triumph
marketingsoph
0
130
Performance Is Good for Brains [We Love Speed 2024]
tammyeverts
12
1.7k
The Limits of Empathy - UXLibs8
cassininazir
1
350
Optimizing for Happiness
mojombo
378
71k
From π to Pie charts
rasagy
0
200
Code Review Best Practice
trishagee
74
20k
Put a Button on it: Removing Barriers to Going Fast.
kastner
60
4.3k
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