Symfony 4 in a nutshell

Richard Melo

@allucardster

About me

  • System Engineer
  • 8+ years experience
  • Fullstack Developer
  • SUDO co-founder

What is Symfony 4?

"It's the symfony's fourth version"

"Symfony it's a full stack framework to develop web applications"

In general:

Symfony 3

  • 42 components
  • Default ORM
  • Default template engine

Symfony 4

  • 15 components
  • There is no default ORM/ODM
  • There is no default template engine

Symfony "Standard edition"

"Because composition is better than inheritance!"

Why?

Symfony turn into a microframework

(in a few words)

Symfony Flex

It's a composer plugin that help us to install and manage Symfony dependencies.

Install bundle

Attach bundle to app kernel

Configure the bundle

Symfony Flex Recipes

Symfony Flex Workflow

  • Look for recipes in http://symfony.sh
  • Install it through composer
# For example:

composer require twig

What if there is no recipe?

  • Create a new one and upload it or...
  • Make the bundle installation by hand

What else is new?

  • Require PHP 7.1 (good bye deprecations)
  • Our application is not a bundle
  • Environment variables instead parameters
  • Single frontal controller based in the environment
  • A file for each bundle configuration
├── bin
├── config
│   ├── packages
│   │   ├── dev
│   │   ├── prod
│   │   ├── test
│   │   ├── doctrine_migrations.yaml
│   │   ├── doctrine.yaml
│   │   ├── framework.yaml
│   │   ├── routing.yaml
│   │   └── twig.yaml
│   ├── routes
│   │   ├── dev
│   │   └── annotations.yaml
│   ├── bundles.php
│   ├── routes.yaml
│   └── services.yaml
├── public
│   └── index.php
├── src
│   ├── Controller
│   ├── Entity
│   ├── Migrations
│   ├── Repository
│   └── Kernel.php
├── templates
│   └── base.html.twig
├── var
│   ├── cache
│   └── log
├── vendor
├── composer.json
├── composer.lock
├── .env
├── .env.dist
└── symfony.lock

Directory Structure

  • Doctrine
  • Twig

For web development using:

Service Container

  • Single file to define services
  • All services are non public by default
  • Autoconfigure by default
  • Autowire by default

Thanks!

References

  • https://es.wikipedia.org/wiki/Symfony
  • http://symfony.com/
  • https://symfony.sh/
  • http://symfony.es/
  • https://medium.com/@fabpot/symfony-4-a-small-screencast-cf6511823f
  • https://medium.com/@fabpot/fabien-potencier-4574622d6a7e
  • https://medium.com/@zawadzki.jerzy/symfony-4-new-hope-dbf99dde91d8

Symfony 4 in a nutshell

By Richard Andres Melo Carrillo

Symfony 4 in a nutshell

  • 784