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"


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 (, followed BY the PHP component ( to enable it to achieve special functions.