SlideShare a Scribd company logo
A dive into
Symfony 4
A long time ago...
Symfony 2 was born
Key Concepts
Components

Bundles

Distributions
Time passed by...
How did it go?
Bene... ma non benissimo :-(
Bene... ma non benissimo :-(
Distributions
Initial idea: one distribution per app type

• Standard Distribution

• Rest Distribution

• Cms Distribution

• ...
Distributions
In Reality: distributions never took off, everybody uses
Standard Distribution and removes stuff manually
Bundles
Initial Idea: organise reusable code in
bundles
Bundles
Have you ever seen this organisation?
ShopBundle

CmsBundle

AdminBundle

...
Bundles
Have you ever seen this organisation?
ShopBundle

CmsBundle

AdminBundle

Common|General| ... | Bundle
Bundles
Vendor code is reusable

Your App code is not
Bundles
Installing/Removing a Bundle is mostly a manual operation

# composer require/remove <bundle>

# add/remove to AppKernel.php

# add/remove configurations
DX initiative
Symfony has a steep learning curve compared to other
frameworks 

The Developer eXperience initiative aims to create a
better onboarding and framework usage experience
DX initiative
Symfony has a steep learning curve compared to other
frameworks 

The Developer eXperience initiative aims to create a
better user experience
Symfony 4 was born...
New Directory Structure
New Directory Structure
The idea behind that is to have a more
intuitive structure
A dive into Symfony 4
New Directory Structure
bin

config

public 

src

var

vendor
New Directory Structure
bin

config

public 

src

var

vendor
index.php
...
favicon.ico
robots.txt
bundles
New Directory Structure
bin

config

public 

src

var

vendor
cache/
log/
session/
New Directory Structure
bin

config

public 

src

var

vendor
Kernel.php
Entity
Repository
Command
Controller
...
No Bundles!
New Directory Structure
bin

config

public 

src

var

vendor
bundles.php

routes.yaml

services.yaml

doctrine.yaml

security.yaml

...

packages/

dev/
routes.yaml

test/
routes.yaml

prod/
routes.yaml
return [

SymfonyBundleFrameworkBundleFrameworkBundle::class => ['all' => true],

SymfonyBundleWebServerBundleWebServerBundle::class => ['dev' => true],

SymfonyBundleMakerBundleMakerBundle::class => ['dev' => true],

SymfonyBundleDebugBundleDebugBundle::class => ['dev' => true, 'test' => true],

SymfonyBundleSecurityBundleSecurityBundle::class => ['all' => true],

];
New Directory Structure
assets

bin

data

config

public 

src

templates

tests

translations

var

vendor
Where is parameter.yaml?
Environment Variables
Environment Variables
Symfony already has them eg.
SYMFONY__ENV
Environment Variables
Now resolved at runtime! You can change
them without touching the app

https://www.12factor.net/config
Environment Variables
doctrine:

dbal:

driver: 'pdo_sqlite'

server_version: '3.15'

charset: utf8mb4

url: ‘%env(resolve:DATABASE_URL)%'


https://symfony.com/blog/new-in-symfony-3-4-advanced-environment-variables
.env
###> symfony/framework-bundle ###
APP_ENV=dev
APP_SECRET=2a0f335581bd72b6077840e29d73ba36
TRUSTED_PROXIES=127.0.0.1,127.0.0.2
TRUSTED_HOSTS=localhost,example.com,127.0.0.1
###< symfony/framework-bundle ###
index.php
if (!isset($_SERVER['APP_ENV'])) {

if (!class_exists(Dotenv::class)) {

throw new RuntimeException('APP_ENV environment variable is not defined.’);

}



(new Dotenv())->load(__DIR__.'/../.env');

}
$env = $_SERVER['APP_ENV'] ?? 'dev';

$debug = (bool) ($_SERVER['APP_DEBUG'] ?? ('prod' !== $env));
Symfony Flex
Flex
A new way to create and evolve a Symfony application

Composition over inheritance

Start small and add what you need
Flex
Integrates into composer workflow 

Automates bundles installation and configuration
Flex
Flex
Flex
{
"bundles": {
"SymfonyBundleFrameworkBundleFrameworkBundle": ["all"]
},
"copy-from-recipe": {
"config/": "%CONFIG_DIR%/",
"public/": "%PUBLIC_DIR%/",
"src/": "%SRC_DIR%/"
},
"composer-scripts": {
"make cache-warmup": "script",
"assets:install --symlink --relative %PUBLIC_DIR%": "symfony-cmd"
},
"env": {
"APP_ENV": "dev",
"APP_DEBUG": "1",
"APP_SECRET": "%generate(secret)%"
},
"gitignore": [
".env",
"/public/bundles/",
"/var/",
"/vendor/"
]
}
https://medium.com/@fabpot/symfony-4-automate-your-workflow-fbbf609b5a1d
symfony.sh
recipes
https://github.com/symfony/recipes 

https://github.com/symfony/recipes-contrib
alias
orm, twig, security, form, validation, ...
So long Standard Edition...
composer require symfony/website-skeleton
composer require symfony/skeleton
So long Silex...
https://symfony.com/blog/the-end-of-silex
Other Bits...
From Sf 3.* to Sf 4
Symfony 3.4 is Symfony 4 with and additional compat layer

Migration path: upgrade to 3.4, remove deprecations,
update to 4 

https://symfony.com/doc/current/setup/flex.html#upgrade-to-flex
Autowiring
Wait 5 minutes... :-P
composer require make
MakerBundle
make:auth

make:command

make:controller

make:crud

make:entity

make:fixtures

make:form

make:functional-test

make:migration

make:serializer:encoder

make:subscriber

make:twig-extension

make:unit-test

make:user

make:validator

make:voter
Fastest PHP Router
https://symfony.com/blog/new-in-symfony-4-1-fastest-php-router
VarDumper Server
https://symfony.com/blog/new-in-symfony-4-1-vardumper-server
Messenger Component
https://symfony.com/blog/new-in-symfony-4-1-messenger-component
Panther
https://symfony.com/blog/introducing-symfony-panther-a-browser-
testing-and-web-scrapping-library-for-php
Moar Improvements
https://symfony.com/blog/new-in-symfony-4-1-exception-improvements

https://symfony.com/blog/new-in-symfony-4-1-session-improvements

https://symfony.com/blog/new-in-symfony-4-1-self-updating-debug-toolbar

https://symfony.com/blog/new-in-symfony-4-1-console-improvements

https://symfony.com/blog/new-in-symfony-4-1-form-field-help

https://symfony.com/blog/new-in-symfony-4-1-faster-serializer

https://symfony.com/blog/new-in-symfony-4-1-misc-improvements-part-1

https://symfony.com/blog/new-in-symfony-4-1-misc-improvements-part-2

https://symfony.com/blog/new-in-symfony-4-1-misc-improvements-part-3

https://symfony.com/blog/new-in-symfony-4-1-misc-improvements-part-4

https://symfony.com/blog/new-in-symfony-4-2-samesite-cookie-configuration

https://symfony.com/blog/new-in-symfony-4-2-varexporter-component

https://symfony.com/blog/new-in-symfony-4-2-intlmessageformatter

https://symfony.com/blog/new-in-symfony-4-2-auto-secure-cookies
Thank you!
Michele Orselli
_orso_
micheleorselli / ideatosrl
mo@ideato.it
https://joind.in/talk/2a90f

More Related Content

What's hot (20)

PDF
Symfony2 revealed
Fabien Potencier
 
PDF
Symfony & Javascript. Combining the best of two worlds
Ignacio Martín
 
PDF
Extending Twig
Gerry Vandermaesen
 
PDF
Curso Symfony - Clase 2
Javier Eguiluz
 
PDF
What's new with PHP7
SWIFTotter Solutions
 
PDF
Symfony Guard Authentication: Fun with API Token, Social Login, JWT and more
Ryan Weaver
 
PDF
Dependency Injection in PHP
Kacper Gunia
 
PDF
Creating and Maintaining WordPress Plugins
Mark Jaquith
 
PDF
Mastering Twig (DrupalCon Barcelona 2015)
Javier Eguiluz
 
PPTX
Zero to SOLID
Vic Metcalfe
 
PDF
symfony on action - WebTech 207
patter
 
PDF
関西PHP勉強会 php5.4つまみぐい
Hisateru Tanaka
 
PDF
Object Oriented Programming for WordPress Plugin Development
mtoppa
 
PDF
Jumping Into WordPress Plugin Programming
Dougal Campbell
 
PDF
November Camp - Spec BDD with PHPSpec 2
Kacper Gunia
 
PPTX
10 Things Every Plugin Developer Should Know (WordCamp Atlanta 2013)
arcware
 
PDF
A Dexterity Intro for Recovering Archetypes Addicts
David Glick
 
PDF
sfDay Cologne - Sonata Admin Bundle
th0masr
 
ODP
Mastering Namespaces in PHP
Nick Belhomme
 
PDF
PHP traits, treat or threat?
Nick Belhomme
 
Symfony2 revealed
Fabien Potencier
 
Symfony & Javascript. Combining the best of two worlds
Ignacio Martín
 
Extending Twig
Gerry Vandermaesen
 
Curso Symfony - Clase 2
Javier Eguiluz
 
What's new with PHP7
SWIFTotter Solutions
 
Symfony Guard Authentication: Fun with API Token, Social Login, JWT and more
Ryan Weaver
 
Dependency Injection in PHP
Kacper Gunia
 
Creating and Maintaining WordPress Plugins
Mark Jaquith
 
Mastering Twig (DrupalCon Barcelona 2015)
Javier Eguiluz
 
Zero to SOLID
Vic Metcalfe
 
symfony on action - WebTech 207
patter
 
関西PHP勉強会 php5.4つまみぐい
Hisateru Tanaka
 
Object Oriented Programming for WordPress Plugin Development
mtoppa
 
Jumping Into WordPress Plugin Programming
Dougal Campbell
 
November Camp - Spec BDD with PHPSpec 2
Kacper Gunia
 
10 Things Every Plugin Developer Should Know (WordCamp Atlanta 2013)
arcware
 
A Dexterity Intro for Recovering Archetypes Addicts
David Glick
 
sfDay Cologne - Sonata Admin Bundle
th0masr
 
Mastering Namespaces in PHP
Nick Belhomme
 
PHP traits, treat or threat?
Nick Belhomme
 

Similar to A dive into Symfony 4 (20)

PDF
The Symfony CLI
Sarah El-Atm
 
PDF
Hands-on with the Symfony2 Framework
Ryan Weaver
 
PDF
IBM Drupal Users Group Discussion on Managing and Deploying Configuration
Development Seed
 
PPTX
Magento Meetup New Delhi- Console
Webkul Software Pvt. Ltd.
 
PDF
Create a Symfony Application from a Drupal Perspective
Acquia
 
PDF
Symfony tips and tricks
Javier Eguiluz
 
ODP
Jbossworld Presentation
Dan Hinojosa
 
PDF
Adopt DevOps philosophy on your Symfony projects (Symfony Live 2011)
Fabrice Bernhard
 
PDF
Recipes for Drupal distributions
Lakshmi Narasimhan Parthasarathy
 
PDF
Introduction to Docker
Tharaka Devinda
 
PDF
So. many. vulnerabilities. Why are containers such a mess and what to do abou...
Eric Smalling
 
PDF
Fabien Potencier "Symfony 4 in action"
Fwdays
 
PDF
Edition of an enterprise software in PHP, feedback
Nicolas Dupont
 
DOCX
C# tutorial
sarangowtham_gunnam
 
PDF
Symfony 4: A new way to develop applications #ipc19
Antonio Peric-Mazar
 
PDF
Advanced Configuration Management with Config Split et al.
Nuvole
 
PPTX
drupal ci cd concept cornel univercity.pptx
rukuntravel
 
PDF
Symfony finally swiped right on envvars
Sam Marley-Jarrett
 
PDF
Progressively enhance your Symfony 4 app using Vue, API Platform, Mercure and...
Les-Tilleuls.coop
 
PPTX
End-to-end CI/CD deployments of containerized applications using AWS services
Massimo Ferre'
 
The Symfony CLI
Sarah El-Atm
 
Hands-on with the Symfony2 Framework
Ryan Weaver
 
IBM Drupal Users Group Discussion on Managing and Deploying Configuration
Development Seed
 
Magento Meetup New Delhi- Console
Webkul Software Pvt. Ltd.
 
Create a Symfony Application from a Drupal Perspective
Acquia
 
Symfony tips and tricks
Javier Eguiluz
 
Jbossworld Presentation
Dan Hinojosa
 
Adopt DevOps philosophy on your Symfony projects (Symfony Live 2011)
Fabrice Bernhard
 
Recipes for Drupal distributions
Lakshmi Narasimhan Parthasarathy
 
Introduction to Docker
Tharaka Devinda
 
So. many. vulnerabilities. Why are containers such a mess and what to do abou...
Eric Smalling
 
Fabien Potencier "Symfony 4 in action"
Fwdays
 
Edition of an enterprise software in PHP, feedback
Nicolas Dupont
 
C# tutorial
sarangowtham_gunnam
 
Symfony 4: A new way to develop applications #ipc19
Antonio Peric-Mazar
 
Advanced Configuration Management with Config Split et al.
Nuvole
 
drupal ci cd concept cornel univercity.pptx
rukuntravel
 
Symfony finally swiped right on envvars
Sam Marley-Jarrett
 
Progressively enhance your Symfony 4 app using Vue, API Platform, Mercure and...
Les-Tilleuls.coop
 
End-to-end CI/CD deployments of containerized applications using AWS services
Massimo Ferre'
 
Ad

More from Michele Orselli (20)

PDF
Tackling Tech Debt with Rector
Michele Orselli
 
PDF
Comunicare, condividere e mantenere decisioni architetturali nei team di svil...
Michele Orselli
 
PDF
A recommendation engine for your applications codemotion ams
Michele Orselli
 
PDF
A recommendation engine for your applications phpday
Michele Orselli
 
PDF
Hopping in clouds - phpuk 17
Michele Orselli
 
PDF
A recommendation engine for your php application
Michele Orselli
 
PDF
Symfony e micro (non così tanto) services
Michele Orselli
 
PDF
Hopping in clouds: a tale of migration from one cloud provider to another
Michele Orselli
 
PDF
Vagrant for real (codemotion rome 2016)
Michele Orselli
 
PDF
Vagrant for real codemotion (moar tips! ;-))
Michele Orselli
 
PDF
Migrare a Symfony 3
Michele Orselli
 
PDF
Vagrant for real
Michele Orselli
 
PDF
Implementing data sync apis for mibile apps @cloudconf
Michele Orselli
 
PDF
Server side data sync for mobile apps with silex
Michele Orselli
 
PDF
Continuous, continuous, continuous
Michele Orselli
 
PDF
Deploy a PHP App on Google App Engine
Michele Orselli
 
PDF
Implementing Server Side Data Synchronization for Mobile Apps
Michele Orselli
 
PDF
Deploy a php app on Google App Engine
Michele Orselli
 
PDF
Sf2 wtf
Michele Orselli
 
PDF
Manage a project portfolio
Michele Orselli
 
Tackling Tech Debt with Rector
Michele Orselli
 
Comunicare, condividere e mantenere decisioni architetturali nei team di svil...
Michele Orselli
 
A recommendation engine for your applications codemotion ams
Michele Orselli
 
A recommendation engine for your applications phpday
Michele Orselli
 
Hopping in clouds - phpuk 17
Michele Orselli
 
A recommendation engine for your php application
Michele Orselli
 
Symfony e micro (non così tanto) services
Michele Orselli
 
Hopping in clouds: a tale of migration from one cloud provider to another
Michele Orselli
 
Vagrant for real (codemotion rome 2016)
Michele Orselli
 
Vagrant for real codemotion (moar tips! ;-))
Michele Orselli
 
Migrare a Symfony 3
Michele Orselli
 
Vagrant for real
Michele Orselli
 
Implementing data sync apis for mibile apps @cloudconf
Michele Orselli
 
Server side data sync for mobile apps with silex
Michele Orselli
 
Continuous, continuous, continuous
Michele Orselli
 
Deploy a PHP App on Google App Engine
Michele Orselli
 
Implementing Server Side Data Synchronization for Mobile Apps
Michele Orselli
 
Deploy a php app on Google App Engine
Michele Orselli
 
Manage a project portfolio
Michele Orselli
 
Ad

Recently uploaded (20)

PDF
SFWelly Summer 25 Release Highlights July 2025
Anna Loughnan Colquhoun
 
PDF
Newgen 2022-Forrester Newgen TEI_13 05 2022-The-Total-Economic-Impact-Newgen-...
darshakparmar
 
PDF
HCIP-Data Center Facility Deployment V2.0 Training Material (Without Remarks ...
mcastillo49
 
PDF
New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
PDF
Using FME to Develop Self-Service CAD Applications for a Major UK Police Force
Safe Software
 
PDF
CIFDAQ Market Insights for July 7th 2025
CIFDAQ
 
PDF
July Patch Tuesday
Ivanti
 
PDF
How Startups Are Growing Faster with App Developers in Australia.pdf
India App Developer
 
PDF
CIFDAQ Weekly Market Wrap for 11th July 2025
CIFDAQ
 
PDF
Log-Based Anomaly Detection: Enhancing System Reliability with Machine Learning
Mohammed BEKKOUCHE
 
PDF
CIFDAQ Token Spotlight for 9th July 2025
CIFDAQ
 
PDF
SWEBOK Guide and Software Services Engineering Education
Hironori Washizaki
 
PPTX
WooCommerce Workshop: Bring Your Laptop
Laura Hartwig
 
PDF
The Builder’s Playbook - 2025 State of AI Report.pdf
jeroen339954
 
PDF
LLMs.txt: Easily Control How AI Crawls Your Site
Keploy
 
PPTX
"Autonomy of LLM Agents: Current State and Future Prospects", Oles` Petriv
Fwdays
 
PPTX
Building Search Using OpenSearch: Limitations and Workarounds
Sease
 
PDF
Fl Studio 24.2.2 Build 4597 Crack for Windows Free Download 2025
faizk77g
 
PDF
Reverse Engineering of Security Products: Developing an Advanced Microsoft De...
nwbxhhcyjv
 
PDF
Bitcoin for Millennials podcast with Bram, Power Laws of Bitcoin
Stephen Perrenod
 
SFWelly Summer 25 Release Highlights July 2025
Anna Loughnan Colquhoun
 
Newgen 2022-Forrester Newgen TEI_13 05 2022-The-Total-Economic-Impact-Newgen-...
darshakparmar
 
HCIP-Data Center Facility Deployment V2.0 Training Material (Without Remarks ...
mcastillo49
 
New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
Using FME to Develop Self-Service CAD Applications for a Major UK Police Force
Safe Software
 
CIFDAQ Market Insights for July 7th 2025
CIFDAQ
 
July Patch Tuesday
Ivanti
 
How Startups Are Growing Faster with App Developers in Australia.pdf
India App Developer
 
CIFDAQ Weekly Market Wrap for 11th July 2025
CIFDAQ
 
Log-Based Anomaly Detection: Enhancing System Reliability with Machine Learning
Mohammed BEKKOUCHE
 
CIFDAQ Token Spotlight for 9th July 2025
CIFDAQ
 
SWEBOK Guide and Software Services Engineering Education
Hironori Washizaki
 
WooCommerce Workshop: Bring Your Laptop
Laura Hartwig
 
The Builder’s Playbook - 2025 State of AI Report.pdf
jeroen339954
 
LLMs.txt: Easily Control How AI Crawls Your Site
Keploy
 
"Autonomy of LLM Agents: Current State and Future Prospects", Oles` Petriv
Fwdays
 
Building Search Using OpenSearch: Limitations and Workarounds
Sease
 
Fl Studio 24.2.2 Build 4597 Crack for Windows Free Download 2025
faizk77g
 
Reverse Engineering of Security Products: Developing an Advanced Microsoft De...
nwbxhhcyjv
 
Bitcoin for Millennials podcast with Bram, Power Laws of Bitcoin
Stephen Perrenod
 

A dive into Symfony 4