Neu in Symfony 5.2: PHP 8-Attribute

Im Vorfeld des Starts des Kurses "Symfony Framework" laden wir potenzielle Studenten und alle ein, sich die Aufzeichnung des Webinars zum Thema "Mikroframes: Vergleich von Symfony- und Symlex-Leistung" anzusehen .



Wir teilen auch die Übersetzung von nützlichem Material.






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