AOP for validating form in laravel PHP

one text

Solution:

PHP doesn't attributes yet, although they are coming (in one form or another) in PHP 8 this fall. Instead, right now most PHP projects that want to use something that feels like an annotation use DocBlock tags.

For instance, Doctrine, which is a very popular ORM for PHP uses ones like:

/**
 * @Column(type="string", length=32, unique=true, nullable=false)
 */
protected $username;

And Symfony uses similar ones such as:

    /**
     * @Route("/blog", name="blog_list")
     */
    public function list()

Actually, Doctrine has a wonderful library on their own for reading these annotation which is what Symfony is using.

Although comments might feel really ugly, modern IDE's like PhpStorm read them fully and they honestly work really nice. I came from .Net a while back and I got used to these once I switched to PhpStorm, especially since they support full namespacing.

Once PHP 8 comes out, these annotation will (probably) be deprecated in favor of true attributes, but we'll have to wait a while for that.

Source