Nuevo en Symfony 5.2: atributos de PHP 8

Anticipándonos al inicio del curso "Symfony Framework", invitamos a los futuros estudiantes ya todo el mundo a ver la grabación del webinar sobre el tema "Microframes: Comparando Symfony y Symlex Performance" .



También compartimos la traducción de material útil.






PHP 8 , , match- constructor property promotion. ( ).





Symfony 5.2 PHP 8 . , :





// :      Doctrine Annotations
use Symfony\Component\Routing\Annotation\Route;

class SomeController
{
    /**
     * @Route("/path", name="action")
     */
    public function someAction()
    {
        // ...
    }
}
      
      



// : ,     PHP 8
use Symfony\Component\Routing\Annotation\Route;

class SomeController
{
    #[Route('/path', name: 'action')]
    public function someAction()
    {
        // ...
    }
}
      
      



Route



Doctrine PHP, . — , : #[…]



! PHP, , doctrine/annotations



, - .





#[Required]



, @Required



Symfony, / :





use Symfony\Contracts\Service\Attribute\Required;

class SomeService
{
    #[Required]
    public Bar $bar;

    #[Required]
    public function setFoo(Foo $foo): void
    {
        // ...
    }
}
      
      



PHP PHP 8, Symfony . — , (, ).






«Symfony Framework».



«: Symfony Symlex».













All Articles