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
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
Stefan Koopmanschap
May 24, 2016
Technology
230
1
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
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
93
PHP Kitchen Nightmares (PHP.FRL)
skoop
0
100
Sustainable open source contributions in your business (CakeFest 2024)
skoop
0
130
Domain-Driven Design: The Basics (SymfonyCon 2023, Brussels)
skoop
0
250
Domain-Driven Design: The Basics (Cakefest)
skoop
0
260
PHP Kitchen Nightmares
skoop
0
82
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
750
Other Decks in Technology
See All in Technology
背中から、背中へ /paying forward to community
naitosatoshi
0
190
自分が詳しくない領域でAIを使う #プロヒス2026
konifar
20
8.2k
組織における AI-DLC 実践
askul
0
240
AWS Summit 2026で見えたSIerにとっての Amazon Quickの位置づけ
maf_0521
0
140
PostgreSQL 19 新機能概要 OSC Hokkaido 2026
nori_shinoda
0
260
グローバルチームと挑むプロダクト開発
sansantech
PRO
1
110
AIで政治は変わるのか? — 中高生と考えたAI時代の民主主義(東海高校サタデープログラム)
eitarosuda
0
300
ご挨拶「10周年を迎える共創ラボのこれまでとこれから」
iotcomjpadmin
0
170
感情と身体を置き去りにしない、エンジニアの生きのこり方 ──いまから、ここから「自分の状態」を扱うという選択
saorimurooka
0
430
本当の”仕事”を手放せる未来が見えた
mu7889yoon
0
210
事業会社は今こそSWEを高給で雇ってWebシステムを内製しよう
masaokb
0
110
40代で“やっとエンジニアになれた”――閉じた学びを開き、空の青さを知る / 20260628 Naoki Takahashi
shift_evolve
PRO
4
1.4k
Featured
See All Featured
How to build a perfect <img>
jonoalderson
1
5.7k
Music & Morning Musume
bryan
47
7.3k
Large-scale JavaScript Application Architecture
addyosmani
515
110k
A brief & incomplete history of UX Design for the World Wide Web: 1989–2019
jct
2
400
SERP Conf. Vienna - Web Accessibility: Optimizing for Inclusivity and SEO
sarafernandez
2
1.5k
GitHub's CSS Performance
jonrohan
1033
470k
AI: The stuff that nobody shows you
jnunemaker
PRO
8
750
Groundhog Day: Seeking Process in Gaming for Health
codingconduct
0
230
The Cult of Friendly URLs
andyhume
79
6.9k
Bridging the Design Gap: How Collaborative Modelling removes blockers to flow between stakeholders and teams @FastFlow conf
baasie
0
600
Noah Learner - AI + Me: how we built a GSC Bulk Export data pipeline
techseoconnect
PRO
0
210
The browser strikes back
jonoalderson
0
1.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