$ symfony new demo --version=dev-master --debug
Demo
Slide 13
Slide 13 text
$ tree -I vendor
$ find . -type f | wc -l
Symfony 4 is lightweight
Only 16 files
vs 31 SE
3300 total
vs 8867 SE
-65%
Slide 14
Slide 14 text
New directory structure
• Less depth, easier to navigate
• Non-PHP files in their own directories
(assets/, templates/)
• Decoupled from Symfony (assets/, src/,
templates/, public/)
Recipes repositories
https://github.com/symfony/recipes
Curated recipes by Symfony core team
https://github.com/symfony/recipes-contrib
Open to all contributions
370+ recipes
Slide 17
Slide 17 text
$ composer show | wc -l
Demo
Only 25 deps
vs 38 + 50 = 88 SE
Aliases
• Shortcuts for common packages (log, behat,
phpunit, …)
• Optimized for Symfony Components (no need
to use the symfony/ prefix, just workflow, dom-crawler, …)
• Opinionated choices (admin, api, orm, mailer, test,
…)
Slide 26
Slide 26 text
Packs
• Bundle several dependencies into a
consistent set (debug, profiler, api, test, …)
$ composer req debug
Slide 27
Slide 27 text
Discover Aliases and Packs
https://flex.symfony.com/
$ vim src/Controller/DefaultController.php
Symfony Maker Bundle
src/ is about YOUR code
Slide 34
Slide 34 text
Symfony 4 helps you
grow your app
with ease
Slide 35
Slide 35 text
$ composer req twig
Adding Twig
Slide 36
Slide 36 text
Never define
your service again*
Slide 37
Slide 37 text
Adding a Twig Extension
Where do I store
the Twig extension
class?
Which file do I
need to change to
register it?
Which tag do I need
to use?
How do I declare a
tag in YAML?
Which interface/class
do I need to implement/
extend? It’s too complex. What
about doing it the dirty
way and do it in the
controller instead?
hmm, ok
Slide 38
Slide 38 text
$ ./bin/console make:twig-extension
Adding a Twig Extension
Add your logic in the
generated class…
DONE!
Slide 39
Slide 39 text
Full Automation works for…
• Twig extensions
• Event listeners
• Doctrine repositories
• Commands
• Voters
• Registration form system
• …
Slide 40
Slide 40 text
Beyond “Hello World”
• Defining some models via Doctrine
• Adding an API for my model
• Managing data with an admin
Slide 41
Slide 41 text
$ composer req orm admin api
Full stack really quick
Slide 42
Slide 42 text
$ composer req orm admin api
Full stack really quick
Slide 43
Slide 43 text
$ ./bin/console make:entity Product --api-resource
Full stack really quick
Slide 44
Slide 44 text
$ vim config/packages/easy_admin.yaml
Full stack really quick
Slide 45
Slide 45 text
$ vim .env
DATABASE_URL="sqlite:///%kernel.project_dir%/var/
data.db"
$ ./bin/console doctrine:database:create
$ ./bin/console doctrine:schema:update --force
Full stack really quick
Slide 46
Slide 46 text
It works!
One line config change
One annotation added
Slide 47
Slide 47 text
No content
Slide 48
Slide 48 text
Typical features
to the next level
Slide 49
Slide 49 text
I want to send emails
from my controller
Slide 50
Slide 50 text
$ composer req symfony/mailer
Symfony Maker Bundle
use Symfony\Component\Mailer\MailerInterface;
public function index(MailerInterface $mailer)
{
$mailer->send(
(new Email())
->from('fabien@symfony.com')
->to('fabien@symfony.com')
->subject('Some subject')
->text('Some text...')
);
MAILER_DSN=smtp://localhost
Slide 51
Slide 51 text
I want to send rich emails
from my controller
Slide 52
Slide 52 text
Symfony Maker Bundle
use Symfony\Component\Mailer\MailerInterface;
public function index(MailerInterface $mailer)
{
$mailer->send(
(new TemplatedEmail())
->from('fabien@symfony.com')
->to('fabien@symfony.com')
->subject('Some subject')
->htmlTemplate('@emails/welcome.html.twig')
->context([
'city' => 'Tunis'
])
);
MAILER_DSN=smtp://localhost
Slide 53
Slide 53 text
I want to send rich and responsive emails
from my controller
Symfony 4 recap
• Auto-configuration for any Composer package
• A Maker bundle to simplify creating files
• No boilerplate code, just business logic
• Controllers and commands as services
• From micro to monolith
• Meta-packages doing a lot for you out of the box
Productivity
boost!
Better DX
Slide 62
Slide 62 text
Why?
Slide 63
Slide 63 text
Featureful and the most downloaded
Slide 64
Slide 64 text
The most advanced API solution
https://api-platform.com/
Slide 65
Slide 65 text
The most advanced e-commerce solution
Slide 66
Slide 66 text
Many admin-gen solutions
https://github.com/EasyCorp/EasyAdminBundle
Slide 67
Slide 67 text
The foundation of the PHP ecosystem
Slide 68
Slide 68 text
$ composer require symfony/console
Truly independent components
(new Console\Application('echo', '1.0.0'))
->register('echo')
->addArgument('foo', Console\Input\InputArgument::OPTIONAL, 'The directory')
->addOption('bar', null, Console\Input\InputOption::VALUE_REQUIRED)
->setCode(function(Console\Input\InputInterface $input,
Console\Output\OutputInterface $output) {
// output arguments and options
})
->getApplication()
->setDefaultCommand('echo', true) // Single command application
->run();
Predictable releases and support
https://symfony.com/releases
•Every month: a patch release
•Every 6 month: a minor release
•Every 2 years: a major release
•On the go: security releases
Slide 71
Slide 71 text
Predictable releases and support
Release
end of
support
+8 months +14 months +36 months +48 months
end of security
support
end of security
support
end of
support
Standard Releases
(3.3, 4.0)
LTS Releases
(2.8, 3.4)
Slide 72
Slide 72 text
Predictable releases and support
3.4
LTS
4.2
Stable
https://symfony.com/releases
The fastest framework around
x2
x3
x4
http://www.phpbenchmarks.com/
Slide 75
Slide 75 text
Scale from micro to monolith
13 files
15 dependencies
start with
… and grow as you see fit
via automation
Slide 76
Slide 76 text
Community oriented
• Code of conduct
https://symfony.com/conduct
• Enforced by the CARE team
https://symfony.com/care
• Respectful Review Comments
https://symfony.com/doc/current/contributing/community/review-comments.html
Diversity initiative
https://symfony.com/diversity