Un mes de Symfony. Abril 2019

Resumen de las novedades que trajo abril a la comunidad de Symfony

Image for post
Image for post
Un mes de Symfony. Abril 2019

Symfony 4.3 depreca los templates en PHP

Nuevas constraints para los tipos numéricos

URL Helper

Mejoras en el componente Intl

use Symfony\Component\Intl\Intl;

\Locale::setDefault('en');

$languages = Intl::getLanguageBundle()->getLanguageNames();
// => ['ab' => 'Abkhazian', ...]

$language = Intl::getLanguageBundle()->getLanguageName('de');
// => 'German'
use Symfony\Component\Intl\Currencies;
use Symfony\Component\Intl\Languages;
use Symfony\Component\Intl\Regions;

\Locale::setDefault('en');

$languages = Languages::getNames();
// => ['ab' => 'Abkhazian', ...]

$language = Languages::getName('de');
// => 'German'

$countries = Regions::getNames();
// => ['AF' => 'Afghanistan', ...]

Componente Inflector

Validador de contraseñas comprometidas

Nuevas assertions para tests

// Before
$this->assertSame(200, $client->getResponse()->getStatusCode());
// After
$this->assertResponseIsSuccessful();

Configuración de servicios con setters inmutables

class MyService
{
use LoggerAwareTrait;

// ...
}

trait LoggerAwareTrait
{
private $logger;

public function withLogger(LoggerInterface $logger)
{
$new = clone $this;
$new->logger = $logger;

return $new;
}
}

$service = new MyService();
$service = $service->withLogger($logger);
# config/services.yaml
services:
MyService:
# ...
calls:
# the TRUE argument turns this into a wither method
- ['withLogger', ['@logger'], true]

Validación automática

/** @ORM\Column(length=5) */
public $zip;

Written by

Entre paseo y paseo con Simba desarrollo en Symfony y React

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store