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
180
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
Domain-Driven Design: The Basics (SymfonyCon 2023, Brussels)
skoop
0
120
Domain-Driven Design: The Basics (Cakefest)
skoop
0
75
PHP Kitchen Nightmares
skoop
0
19
Domain Driven Design - The Basics (TechTuesday XXL, Tilburg)
skoop
0
76
7 Lessons You Can Learn From Disney Movies (SymfonyCon 2022)
skoop
0
230
Mental Health in the Workplace (SymfonyCon 2019, Amsterdam)
skoop
0
570
Mental Health in the Workplace (PHPugle)
skoop
0
56
Mental Health in the Workplace (DeventerPHP)
skoop
0
86
Mental Health in the workplace (PHPTilburg, 09-01-2019)
skoop
0
67
Other Decks in Technology
See All in Technology
Getting started with controlling LEGO using Swift
hcrane
0
140
生成AIサービスPanorama AIご説明資料
sdt
0
300
BDD(Cucumber)コミュニティが無料提供しているコンテンツの紹介と現在起きている危機
nihonbuson
4
750
データ化エンジニアとしての1年を振り返る
sansantech
PRO
3
260
SaaS型Webサービス「カオナビ」のチーム開発でPackage by Featureを取り入れた話/Implementing Package by Feature in kaonavi
kaonavi
0
110
CI/CDがあたりまえの今の時代にAPIテスティングツールに求められていること / CI/CD Test Night #7
k1low
12
3.1k
SREsのためのSRE定着ガイド
netmarkjp
10
1.7k
Challenges - Open Farming Hackdays 2024
loleg
0
580
大規模言語モデル開発のための日本語 Instruction データセット作成の取り組み
kunishou
1
180
期待しすぎずに取り組む両面 TypeScript
shozawa
4
580
KubeCon EU 2024 : Knative Maintainers Session
salaboy
0
380
Azureコストは水道代/The_47th_Tokyo_Jazug
aeonpeople
3
390
Featured
See All Featured
JavaScript: Past, Present, and Future - NDC Porto 2020
reverentgeek
39
4.3k
Building Better People: How to give real-time feedback that sticks.
wjessup
350
18k
5 minutes of I Can Smell Your CMS
philhawksworth
199
19k
RailsConf & Balkan Ruby 2019: The Past, Present, and Future of Rails at GitHub
eileencodes
124
32k
Debugging Ruby Performance
tmm1
68
11k
The Brand Is Dead. Long Live the Brand.
mthomps
48
22k
What's new in Ruby 2.0
geeforr
335
31k
Testing 201, or: Great Expectations
jmmastey
27
6.3k
Java REST API Framework Comparison - PWX 2021
mraible
PRO
18
6.8k
Git: the NoSQL Database
bkeepers
PRO
421
63k
Designing for humans not robots
tammielis
247
25k
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
5
1.4k
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