Status about
Tuesday May 4th, 2015 – Helsinki – Finland
Slide 2
Slide 2 text
WHO AM I?
• Head of
• Trainer & Developer
• Enjoying sharer
• Contributor to
Slide 3
Slide 3 text
3
Slide 4
Slide 4 text
https://sensiolabs.com
Slide 5
Slide 5 text
5
Slide 6
Slide 6 text
1.
WHAT
IS
SYMFONY
2.
WHAT’S
NEW?
6
Summary
Slide 7
Slide 7 text
7
Slide 8
Slide 8 text
8
Slide 9
Slide 9 text
WHAT
IS
SYMFONY?
9
Round
1
Slide 10
Slide 10 text
Framework
Philosophy
Community
Slide 11
Slide 11 text
No content
Slide 12
Slide 12 text
No content
Slide 13
Slide 13 text
Dependency
Injection
BrowserKit
ClassLoader
Config
CssSelector
Debug
DomCrawler
Filesystem
Finder
HttpFoundation
HttpKernel
Locale Intl Icu
OptionsResolver
Process
PropertyAccess
Serializer Stopwatch Templating Translation
Validator
ExpressionLanguage
Console
yaml
EventDispatcher
Routing
Security
Form
Slide 14
Slide 14 text
No content
Slide 15
Slide 15 text
No content
Slide 16
Slide 16 text
https://symfony.com/roadmap
Slide 17
Slide 17 text
INTRODUCING…
THE
COMMUNITY!
17
Round
1
-‐
What
is
Symfony
Slide 18
Slide 18 text
+1,000 code contributors
Slide 19
Slide 19 text
+700 documentation
contributors
Slide 20
Slide 20 text
+2,500 community
bundles
Slide 21
Slide 21 text
And many open source projects!
Slide 22
Slide 22 text
SIMPLIFY
THE
DEVS’
LIFE:
IDE
INTEGRATION
22
Round
1
-‐
What
is
Symfony
Slide 23
Slide 23 text
No content
Slide 24
Slide 24 text
SIMPLIFY
THE
DEVS’
LIFE:
EASY
INSTALLATION
24
Round
1
-‐
What
is
Symfony
Slide 25
Slide 25 text
Easy installation with Composer
Slide 26
Slide 26 text
Easy
installation
26
Slide 27
Slide 27 text
Easy
installation
with
the
installer
27
Slide 28
Slide 28 text
THE
PHILOSOPHY
28
Round
1
-‐
What
is
Symfony
Slide 29
Slide 29 text
# web/app.php
use Symfony\Component\HttpFoundation\Request;
$kernel = new AppKernel('prod', false);
$kernel->loadClassCache();
$request = Request::createFromGlobals();
$response = $kernel->handle($request);
$response->send();
$kernel->terminate($request, $response);
Slide 30
Slide 30 text
30
Separation of Concerns Implementation
Controller
View
Model
Modifies the model
Returns model data
Renders the view
The Controller analyses the user request,
calls the Model and passes data to the View.
The View layer formats data in a
dedicated format (html, json…)
The Model stores the business logic
and classes that manipulate data.
R
Router
Response
Request
/hello/fabien
Slide 31
Slide 31 text
30
Separation of Concerns Implementation
Controller
View
Model
Modifies the model
Returns model data
Renders the view
The Controller analyses the user request,
calls the Model and passes data to the View.
The View layer formats data in a
dedicated format (html, json…)
The Model stores the business logic
and classes that manipulate data.
R
Router
Response
Request
/hello/fabien
Slide 32
Slide 32 text
30
Separation of Concerns Implementation
Controller
View
Model
Modifies the model
Returns model data
Renders the view
The Controller analyses the user request,
calls the Model and passes data to the View.
The View layer formats data in a
dedicated format (html, json…)
The Model stores the business logic
and classes that manipulate data.
R
Router
Response
Request
/hello/fabien
Slide 33
Slide 33 text
VC
Framework
31
Slide 34
Slide 34 text
namespace Acme\DemoBundle\Controller;
use Sensio\Bundle\FrameworkExtraBundle\[…]\Route;
use Symfony\Component\HttpFoundation\Response;
class DefaultController
{
/** @Route("/hello/{name}") */
public function indexAction($name)
{
return new Response('Hello '.$name);
}
}
Slide 35
Slide 35 text
class DefaultController extends Controller
{
/** @Route("/hello/{name}") */
public function indexAction($name)
{
return $this->render(
'AcmeDemoBundle:Default:index.html.twig',
[ 'name' => $name ]
);
}
}
Slide 36
Slide 36 text
class DefaultController
{
/**
* @Route("/schedule")
* @Template
*/
public function indexAction()
{
return [ 'title' => 'Schedule' ];
}
}
Slide 37
Slide 37 text
35
Round
1
-‐
What
is
Symfony
GREAT
TOOL
TO
CODE
FASTER:
TWIG
{% block title 'Welcome!' %}
{% block body '' %}
base.html.twig
Slide 42
Slide 42 text
base.html.twig
layout.html.twig
index.html.twig
Slide 43
Slide 43 text
Twig is a modern template engine
for PHP
▪ Fast
▪ Concise and rich syntax
▪ Automatic output escaping
▪ Modern features
▪ Extensible
Slide 44
Slide 44 text
Twig is a modern template engine
for PHP
▪ Fast
▪ Concise and rich syntax
▪ Automatic output escaping
▪ Modern features
▪ Extensible
twig.sensiolabs.org
Slide 45
Slide 45 text
SIMPLIFY
THE
DEVS’
LIFE:
DEVELOPMENT
TOOLS
42
Round
1
-‐
What
is
Symfony
Slide 46
Slide 46 text
No content
Slide 47
Slide 47 text
No content
Slide 48
Slide 48 text
No content
Slide 49
Slide 49 text
No content
Slide 50
Slide 50 text
SIMPLIFY
THE
DEVS’
LIFE:
CODE
GENERATORS
47
Round
1
-‐
What
is
Symfony
Slide 51
Slide 51 text
$ php app/console generate:bundle
Slide 52
Slide 52 text
No content
Slide 53
Slide 53 text
$ php app/console generate:doctrine:crud
Slide 54
Slide 54 text
GREAT
TOOL
TO
CODE
FASTER:
ROUTING
COMPONENT
51
Round
1
-‐
What
is
Symfony
Slide 55
Slide 55 text
The router maps a
url pattern to a set
of internal
parameters.
Slide 56
Slide 56 text
The router maps a
url pattern to a set
of internal
parameters.
It’s about matching a request to
a callable => action
•FOSUserBundle
•HWIOAuthBundle (Oauth)
•…
authentication
Third party library
Slide 99
Slide 99 text
/**
* @Security("has_role('ROLE_ADMIN')")
*/
public function editAction($id)
{
// granted to perform an action...
}
Using annotations to secure an action
authorization
Slide 100
Slide 100 text
Advanced authorization method: Voters
Slide 101
Slide 101 text
No content
Slide 102
Slide 102 text
No content
Slide 103
Slide 103 text
WHAT’S
NEW?
98
Round
2
Slide 104
Slide 104 text
SYMFONY
3.0
99
Round
2
-‐
What
is
new?
Slide 105
Slide 105 text
100
Slide 106
Slide 106 text
100
Slide 107
Slide 107 text
3.0
Slide 108
Slide 108 text
What
is
it
going
to
be?
• Compared to 2.x? => No new feature
• Removal of descending compatibility layer
• Keeping the compatibility when possible
• >= PHP 5.5.9
Slide 109
Slide 109 text
Symfony
2.8
LTS?
• Last refactoring of the 2.X branch
• Last deprecations
• New features
• It will be the 3.0 + descending layers of
compatibility
• >= PHP 5.3.9
Slide 110
Slide 110 text
How
to
handle
the
migration?
• UPGRADE.md
• Do not ignore the deprecation notices
• grep/ack ;)
• PHPStorm
•
• error_reporting(E_ALL–E_USER_DEPRECATED)
https://knpuniversity.com/blog/upgrading-‐symfony-‐2.7
Slide 111
Slide 111 text
WHAT
IS
GOING
TO
CHANGE
IN
YOUR
APPLICATIONS?
105
Round
2
-‐
What
is
new?
Configuration
variables
• `twig.form.resources`
becomes`twig.form_themes`
• Removal
of
`framework.csrf_protection.field_name`
• `pattern`
becomes
`path`
for
the
routes
Slide 114
Slide 114 text
Twig
templates
• Removal
of
the
{% render %} tag
• Removal
of
the
{% include %} tag
• Removal
of
the
global
variable
`app.security`
Slide 115
Slide 115 text
ClassLoader
• Removal
of
the
ApcUniversalClassLoader
• Removal
of
the
DebugClassLoader
(use
the
Debug’s
one)
• Removal
of
the
DebugUniversalClassLoader
• Removal
of
the
UniversalClassLoader
(use
Composer)
Slide 116
Slide 116 text
Dependency
Injection
Component
• No
more
«
scopes
».
• «
synchronized
»
services
disappear.
• «
factory-‐*
»
attributes
become
«
factory
»
tags.
Slide 117
Slide 117 text
Routing
• Attribut
Route::$pattern becomes
Route::$path
• ApacheUrlMatcher
disappears
(mind
to
remove
it
in
your
front
controllers)
Slide 118
Slide 118 text
Console
• DialogHelper
replaced
by
Question
• ProgressBarHelper
replaced
by
ProgressBar
• TableHelper
replaced
by
Table
• Removal
of
the
Application::asText()
and::asXml()
• Removal
of
the
Command::asText()
and
::asXml()
• Removal
of
the
InputDefinition::asText()
and
::asXml()
HTTP
Kernel
• Removal
of
the
leagcy
LoggerInterface
• Kernel::init() disappears
for
the
__construct()
• HttpCache::getEsi()replaced
by
HttpCache::getSurrogate()
Slide 121
Slide 121 text
Form
component
• Form::bind()
-‐>
Form::submit()
/
Form::handleRequest()
• No
more
Form::isBound()
neither
Form::getErrorsAsString()
• AbstractType::setDefaultOptions()
-‐>
AbstractType::configureOptions()
• AbstractTypeExtension::setDefaultOptions()
-‐>
AbstractTypeExtension::configureOptions()
• No
more
of
the
«
virtual
»
option
Slide 122
Slide 122 text
Locale
component
• The
component
is
removed.
• Use
the
Intl
component
instead.
Slide 123
Slide 123 text
OptionsResolver
component
• Removal
/
renaming
of
several
methods
of
the
OptionsResolver
class.
Slide 124
Slide 124 text
Process
component
• Removal
of
the
Process::getStdin()
and
Process::setStdin()
• Refactoring
coming
up
in
2.8
Slide 125
Slide 125 text
119
Slide 126
Slide 126 text
119
Slide 127
Slide 127 text
Property
Access
component
• Removal
of
the
PropertyAccess::getPropertyAccessor()
Slide 128
Slide 128 text
FrameworkBundle
• Controller::getRequest()
disappears.
• $this->get('request’) disappears.
• Use
the
RequestStack.
Slide 129
Slide 129 text
Security
• security.context
service
disappears
• Use
the
security.token_storage
&
security.authorization_checker
• Removal
of
the
app.security
in
Twig
-‐>
use
is_granted()
Slide 130
Slide 130 text
Serializer
• Removal
of
the
JsonDecode::getLastError()
• Removal
of
the
JsonEncode::getLastError()
• Removal
of
the
JsonEncoder::getLastError()
Slide 131
Slide 131 text
Translation
• Removal
of
the
Translator::setFallbackLocale()
Slide 132
Slide 132 text
Validator
• ViolationBuilder
/
ExecutionContext
-‐>
addViolation()
replaced
by
buildViolation().
• API
BC
(use
of
the
2.5
version).
• Function
Twig
form_enctype()
disappears.
• No
more
«
type
»
option
in
the
ISBN
constraint.
• No
more
«
methods
»
option
in
the
Callback
constraint.
• No
more
«
deep
»
option
in
the
Valid
constraint.
• The
constraints
Optional
&
Required
disappear.
Slide 133
Slide 133 text
126
Slide 134
Slide 134 text
126
Slide 135
Slide 135 text
No content
Slide 136
Slide 136 text
No content
Slide 137
Slide 137 text
The point is to keep everyone
on the road.
Smooth migration!