SlideShare a Scribd company logo
My
Symfony
WTF
Michele Orselli
CTO@Ideato
@_orso_
mo@ideato.it

Who am I?
Why a talk on WTF?

why a talk on WTF?
I♥

why a talk on WTF?
but...

why a talk on WTF?
why a talk on WTF?
why a talk on WTF?
why a talk on WTF?
why a talk on WTF?
symfony 1 was focused on
Rapid Application Development

the (old) times?
Symfony2 is focused on
Application Development

the shiny new thing
the shiny new thing
the shiny new thing
the shiny new thing
speed as selling point
create-project symfony/framework-standard-edition ./foo 2.3.0

installation
cache/log permissions
cache/log permissions
php app/console cache:clear

cache/log permissions
cache/log permissions
cache all the things (in dev too)!
http://symfony.com/doc/current/book/templating.html

cache all the things (in dev too)!
config.yml:
twig:
cache:

false

user session in cache!
uhm, wait a minute...
user session in cache!
capifony?
idephix? :-P

user session in cache!
config.yml:
framework:
session:
save_path: "%kernel.root_dir%/sessions/"

user session in cache!
sf2 in da cloud
sf2 in da cloud
http:/
/www.ideato.it/planet-ideato/symfony2-su-google-app-engine/

symfony2 needs a writable filesystem
symfony2 uses some restricted functions
you can warmup cache, but paths are absolute
the problem is not only limited to symfony (eg: assetic)

sf2 in da cloud
sf2 in da cloud
/**
* @ORMEntity(repositoryClass="IdeatoOfferBundleRepositoryCityRepository")
* @ORMTable(name="city")
*/
class City
{
/**
* @ORMId
* @ORMColumn(type="integer")
* @ORMGeneratedValue(strategy="AUTO")
*/
private $id;
/**
* @ORMColumn(type="string", length=255)
* @AssertNotBlank()
*/
private $name;

annotations
use DoctrineORMMapping as ORM;
use SymfonyComponentValidatorConstraints as Assert;

/**
* @ORMEntity(repositoryClass="IdeatoOfferBundleRepositoryCityRepository")
* @ORMTable(name="city")
*/
class City
{
/**
* @ORMId
* @ORMColumn(type="integer")
* @ORMGeneratedValue(strategy="AUTO")
*/
private $id;
/**
* @ORMColumn(type="string", length=255)
* @AssertNotBlank()
*/
private $name;

annotations
@ParamConverter

do you need everything?
/**
* @ParamConverter("post", class="SensioBlogBundle:Post")
*/
public function showAction(Post $post)
{
...
}

do you need everything?
/**
* @ParamConverter("post", class="SensioBlogBundle:Post")
*/
public function showAction(Post $post)
{
...
}
public function showAction(Post $post)
{
...
}

do you need everything?
/**
* @ParamConverter("post", class="SensioBlogBundle:Post")
*/
public function showAction(Post $post)
{
...
}
public function showAction(Post $post)
{
...
}
public function showAction(Post $post, Comment $comment)
{
...
}

do you need everything?
/**
* @ParamConverter("post", class="SensioBlogBundle:Post")
*/
public function showAction(Post $post)
{
...
}
public function showAction(Post $post)
{
...
}
public function showAction(Post $post, Comment $comment)
{
...
}

kill the magic?
public function showAction($post_id)
{
$post = $this->getRepository(‘Posts’)
->findOneById($post_id);
}

explicit vs implicit
use DoctrineDBALTypesType;
use DoctrineDBALPlatformsAbstractPlatform;
 
/**
* NewObject datatype
*/
class NewObjectType extends Type
{
public function convertToPHPValue($value, AbstractPlatform $platform)
{
$listeners = $platform -> getEventManager() -> getListeners('getContainer');
 
$listener = array_shift($listeners);
$container = $listener -> getContainer();
 
return $container -> get('service');
}
}

if u can it doesn’t mean you have to
class A
{
protected $first_service;
protected $second_service;
public function __construct(ContainerInterface $container)
{
$this->first_service = $container->get(‘firstService’);
$this->second_service = $container->get(‘secondService’);
}
}

passing around the DIC is bad
class A
{
protected $first_service;
protected $second_service;
public function __construct(FirstService $first, SecondService $second)
{
$this->first_service = $first;
$this->second_service = $second;
}
}

in services.yml:
services:
my.service:
arguments:
- "@first_service"
- "@second_service"
class: MyClassA

passing around the DIC is bad
everything is a bundle
mopa_bootstrap:
version:
~
form:
templating:
MopaBootstrapBundle:Form:fields.html.twig
horizontal_label_class: col-lg-3
horizontal_input_wrapper_class: col-lg-9
row_wrapper_class:
form-group
render_fieldset:
true
render_collection_item: true
show_legend:
true
show_child_legend:
false
checkbox_label:
both
render_optional_text: true
render_required_asterisk: false
error_type:
~
tooltip:
icon:
icon-info-sign
placement:
top
tabs:
class:
nav nav-tabs
popover:
icon:
icon-info-sign
placement:
top
collection:
widget_remove_btn:
attr:
class:
btn
icon:
~
icon_color:
~
widget_add_btn:
attr:
class:
btn
icon:
~
icon_color:
~
navbar:
template:
MopaBootstrapBundle:Navbar:navbar.html.twig
initializr:
meta:
title:
MopaBootstrapBundle
description:
MopaBootstrapBundle
keywords:
MopaBootstrapBundle, Twitter Bootstrap, HTML5 Boilerplate
author_name:
My name
author_url:
#
feed_atom:
~
feed_rss:
~
sitemap:
~
nofollow:
false
noindex:
false
dns_prefetch:
# Default:
- //ajax.googleapis.com
google:
wt:
~
analytics:
~
diagnostic_mode:
false

configuration (Mopa)...
fos_user:
db_driver:
~ # Required
user_class:
~ # Required
firewall_name:
~ # Required
model_manager_name:
~
use_listener:
true
use_username_form_type: true
from_email:
address:
webmaster@example.com
sender_name:
webmaster
profile:
form:
type:
fos_user_profile
name:
fos_user_profile_form
validation_groups:
# Defaults:
- Profile
- Default
change_password:
form:
type:
name:
validation_groups:
# Defaults:
- ChangePassword
- Default
registration:
confirmation:
enabled:
template:
from_email:
address:
sender_name:
form:
type:
name:
validation_groups:

fos_user_change_password
fos_user_change_password_form

false
FOSUserBundle:Registration:email.txt.twig
~ # Required
~ # Required

resetting:
token_ttl:
86400
email:
template:
FOSUserBundle:Resetting:email.txt.twig
from_email:
address:
~ # Required
sender_name:
~ # Required
form:
type:
fos_user_resetting
name:
fos_user_resetting_form
validation_groups:
# Defaults:
- ResetPassword
- Default
service:
mailer:
fos_user.mailer.default
email_canonicalizer: fos_user.util.canonicalizer.default
token_generator:
fos_user.util.token_generator.default
username_canonicalizer: fos_user.util.canonicalizer.default
user_manager:
fos_user.user_manager.default
template:
engine:
twig
group:
group_class:
~ # Required
group_manager:
fos_user.group_manager.default
form:
type:
fos_user_group
name:
fos_user_group_form
validation_groups:
# Defaults:
- Registration
- Default

fos_user_registration
fos_user_registration_form

# Defaults:
- Registration
- Default

configuration (FosUserBundle)...
configuration is just another way of
programming

configuration...
is there a way to create decoupled,
maintainable code?

configuration...
libraries

configuration...
src
!"" Acme
#"" CoreDomain
$
!"" User
$
#"" User.php
$
#"" UserId.php
$
!"" UserRepository.php
!"" CoreDomainBundle
#"" Repository
$   !"" InMemoryUserRepository.php
!"" AcmeCoreDomainBundle.php

http:/
/williamdurand.fr/2013/08/07
/ddd-with-symfony2-folder-structure-and-code-first/
http:/
/whitewashing.de

ddd, code first, ...
wrap up

Wrap up
after all Symfony2 is just a
framework

Wrap up
framework != architecture

Wrap up
do you need that feature?

Wrap up
think in advance

Wrap up
keep things decoupled

Wrap up
Thank you!
@_orso_

that’s all folks!

mo@ideato.it
Pics Credits
wtf per minute: http://www.codinghorror.com/blog/2009/02/whos-your-coding-buddy.html
pills: http://www.daygame.com/2013/blog/swallowing-the-red-pill/
umarell: http://www.informarexresistere.fr/
clouds: http://www.flickr.com/photos/uncle_jerry/49341110/
gae: http://venturebeat.files.wordpress.com/2013/05/google-app-engine-php-zend.jpg

that’s all folks!

More Related Content

PDF
Symfony internals [english]
PDF
Create a Symfony Application from a Drupal Perspective
PDF
Symfony 2
PDF
Symfony tips and tricks
PDF
Symfony 2.0 on PHP 5.3
PDF
PHP 5.3 in practice
PDF
High Quality Symfony Bundles tutorial - Dutch PHP Conference 2014
PDF
Symfony 4 & Flex news
Symfony internals [english]
Create a Symfony Application from a Drupal Perspective
Symfony 2
Symfony tips and tricks
Symfony 2.0 on PHP 5.3
PHP 5.3 in practice
High Quality Symfony Bundles tutorial - Dutch PHP Conference 2014
Symfony 4 & Flex news

What's hot (18)

PDF
Symfony Components 2.0 on PHP 5.3
PDF
The Coolest Symfony Components you’ve never heard of - DrupalCon 2017
KEY
Keeping it small: Getting to know the Slim micro framework
PDF
Keeping it Small: Getting to know the Slim Micro Framework
PDF
A dive into Symfony 4
PDF
Keeping it small - Getting to know the Slim PHP micro framework
PDF
ReactPHP
PPT
Php introduction
PDF
Bullet: The Functional PHP Micro-Framework
PPT
Slim RedBeanPHP and Knockout
PPTX
Symfony2 Introduction Presentation
ODP
Symfony CMF - PHP Conference Brazil 2011
PDF
Building Modern and Secure PHP Applications – Codementor Office Hours with Be...
PDF
The Naked Bundle - Symfony Barcelona
PDF
Symfony console: build awesome command line scripts with ease
PDF
Developing apps using Perl
PPT
Php Tutorial | Introduction Demo | Basics
Symfony Components 2.0 on PHP 5.3
The Coolest Symfony Components you’ve never heard of - DrupalCon 2017
Keeping it small: Getting to know the Slim micro framework
Keeping it Small: Getting to know the Slim Micro Framework
A dive into Symfony 4
Keeping it small - Getting to know the Slim PHP micro framework
ReactPHP
Php introduction
Bullet: The Functional PHP Micro-Framework
Slim RedBeanPHP and Knockout
Symfony2 Introduction Presentation
Symfony CMF - PHP Conference Brazil 2011
Building Modern and Secure PHP Applications – Codementor Office Hours with Be...
The Naked Bundle - Symfony Barcelona
Symfony console: build awesome command line scripts with ease
Developing apps using Perl
Php Tutorial | Introduction Demo | Basics
Ad

Viewers also liked (11)

PDF
The View From Inside
PDF
How kris-writes-symfony-apps-london
PDF
Event sourcing quick introduction
PDF
The IoC Hydra - Dutch PHP Conference 2016
PDF
Drupal8 for Symfony Developers
PDF
DDD on example of Symfony (SfCampUA14)
PDF
Domain-driven Design in PHP and Symfony - Drupal Camp Wroclaw!
PDF
Matters of State
PDF
Loosely Coupled DDD
ODP
Rich domain model with symfony 2.5 and doctrine 2.5
PDF
CQRS and Event Sourcing in a Symfony application
The View From Inside
How kris-writes-symfony-apps-london
Event sourcing quick introduction
The IoC Hydra - Dutch PHP Conference 2016
Drupal8 for Symfony Developers
DDD on example of Symfony (SfCampUA14)
Domain-driven Design in PHP and Symfony - Drupal Camp Wroclaw!
Matters of State
Loosely Coupled DDD
Rich domain model with symfony 2.5 and doctrine 2.5
CQRS and Event Sourcing in a Symfony application
Ad

Similar to Sf2 wtf (20)

PDF
Living With Legacy Code
PDF
PHP7 is coming
PDF
How Symfony changed my life (#SfPot, Paris, 19th November 2015)
PDF
PHP Frameworks: I want to break free (IPC Berlin 2024)
PDF
The state of DI - DPC12
PDF
How Symfony Changed My Life
PDF
The Naked Bundle - Symfony Usergroup Belgium
PDF
The state of DI in PHP - phpbnl12
PDF
Symfony2 San Francisco Meetup 2009
PDF
Hands-on with the Symfony2 Framework
PDF
Converting your JS library to a jQuery plugin
ODP
The why and how of moving to php 5.4
PPTX
PHP in 2018 - Q4 - AFUP Limoges
PDF
Symfony2 - WebExpo 2010
PDF
Symfony2 - WebExpo 2010
PDF
Symfony2 - OSIDays 2010
PDF
The Naked Bundle - Symfony Live London 2014
PDF
The new features of PHP 7 - Enrico Zimuel - Codemotion Milan 2016
PDF
The new features of PHP 7
PDF
Symfony War Stories
Living With Legacy Code
PHP7 is coming
How Symfony changed my life (#SfPot, Paris, 19th November 2015)
PHP Frameworks: I want to break free (IPC Berlin 2024)
The state of DI - DPC12
How Symfony Changed My Life
The Naked Bundle - Symfony Usergroup Belgium
The state of DI in PHP - phpbnl12
Symfony2 San Francisco Meetup 2009
Hands-on with the Symfony2 Framework
Converting your JS library to a jQuery plugin
The why and how of moving to php 5.4
PHP in 2018 - Q4 - AFUP Limoges
Symfony2 - WebExpo 2010
Symfony2 - WebExpo 2010
Symfony2 - OSIDays 2010
The Naked Bundle - Symfony Live London 2014
The new features of PHP 7 - Enrico Zimuel - Codemotion Milan 2016
The new features of PHP 7
Symfony War Stories

More from Michele Orselli (20)

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

Recently uploaded (20)

PDF
NewMind AI Weekly Chronicles - August'25 Week I
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PDF
Spectral efficient network and resource selection model in 5G networks
PPTX
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PDF
Approach and Philosophy of On baking technology
PDF
Review of recent advances in non-invasive hemoglobin estimation
PDF
Encapsulation theory and applications.pdf
PDF
Chapter 3 Spatial Domain Image Processing.pdf
PDF
Empathic Computing: Creating Shared Understanding
PDF
Network Security Unit 5.pdf for BCA BBA.
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PDF
Electronic commerce courselecture one. Pdf
DOCX
The AUB Centre for AI in Media Proposal.docx
PPTX
Big Data Technologies - Introduction.pptx
NewMind AI Weekly Chronicles - August'25 Week I
Mobile App Security Testing_ A Comprehensive Guide.pdf
Agricultural_Statistics_at_a_Glance_2022_0.pdf
Spectral efficient network and resource selection model in 5G networks
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
Approach and Philosophy of On baking technology
Review of recent advances in non-invasive hemoglobin estimation
Encapsulation theory and applications.pdf
Chapter 3 Spatial Domain Image Processing.pdf
Empathic Computing: Creating Shared Understanding
Network Security Unit 5.pdf for BCA BBA.
Diabetes mellitus diagnosis method based random forest with bat algorithm
“AI and Expert System Decision Support & Business Intelligence Systems”
Digital-Transformation-Roadmap-for-Companies.pptx
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
Electronic commerce courselecture one. Pdf
The AUB Centre for AI in Media Proposal.docx
Big Data Technologies - Introduction.pptx

Sf2 wtf