Symfony 5.2の新機能:PHP8属性

「SymfonyFramework」コースの開始見越して、「Microframes:Comparing Symfony and Symlex Performance」というトピックに関するウェビナーの録画を、将来の学生とすべての人に見てもらいます。



また、有用な資料の翻訳も共有しています。






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