Use

Annotation is simple to use, and as with a class, the first class is introduced using the USE keyword, followed by the annotation

use Swoft\Http\Server\Annotation\Mapping\Controller; 

/**
 * 类注释
 *
 * @since 2.0
 * 
 * @Controller("a")
 */
class A
{
}
  • Line 1th introduces the annotation class, like a normal class
  • Line 8th uses annotations, formatting @类名 , and some class names will have parameters in them, more than such annotation"a"

Principle

Why does PHP's normal annotation have a ability? In fact, it is very simple, through the PHP reflection to get the class inside is all annotations (https://www.php.net/manual/zh/book.reflection.php), followed BY the PHP component (https://github.com/doctrine/annotations) to enable it to achieve special functions.

/docs/2.x/en/annotation/usage.html
progress-bar