Download the PHP package littler/annotation without Composer
On this page you can find all versions of the php package littler/annotation. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Please rate this library. Is it a good library?
Informations about the package annotation
annotation for ThinkPHP6
安装
composer require littler/annotation
配置
配置文件位于
config/annotation.php
使用方法
自定义注解
创建注解
通过命令行模式创建,例如创建一个 User 的注解,分为以下三部分
-
添加注解命令行
修改 tp6 命令行文件位置:
config/console.php
添加以下内容:
-
生成注解类(annotation)
命令行操作:例如生成一个 User 类注解
生成完成的注解类,如下:
只需要完成 TODO 位置对注解参数的定义,可以参考 TP6 自带的注解类
-
生成注解处理器类(handler)
命令行操作:例如生成一个 User 类注解处理器类
生成完成的注解类,如下:
只需要完成 TODO 注解的解释进行操作处理哦,
cls()
方法是针对注解类@Target()
中包含CLASS
时才会被调用 ,func()
方法是针对注解类@Target()
中包含METHOD
时才会被调用。参数说明:
参数名 简介 \$refClass \ReflectionClass
当前注解类的反射对象\$annotation 当前类注解的参数对象( cls和func的annotation一样
)\$route 当前类的 TP6
\think\Route\RuleGroup
路由对象\$refMethod \ReflectionMethod
当前注解类访问方法的反射对象\$rule 当前方法的 TP6
\think\route\RuleItem
路由规则对象上述只是对参数做的阐述,实际参数意义和作用具体看自身业务。
-
添加到用户自定义的注解配置中
文件位置:
config/annotation.php
添加内容:
IDE Support
Some IDEs already provide support for annotations:
- Eclipse via the Symfony2 Plugin http://symfony.dubture.com/
- PHPStorm via the PHP Annotations Plugin http://plugins.jetbrains.com/plugin/7320 or the Symfony2 Plugin http://plugins.jetbrains.com/plugin/7219
All versions of annotation with dependencies
PHP Build Version
Package Version
Requires
topthink/framework Version
^6.0
doctrine/annotations Version ^1.0
php-di/phpdoc-reader Version ^2.0
symfony/class-loader Version ^3.0
erusev/parsedown Version ^1.0
doctrine/annotations Version ^1.0
php-di/phpdoc-reader Version ^2.0
symfony/class-loader Version ^3.0
erusev/parsedown Version ^1.0
The package littler/annotation contains the following files
Loading the files please wait ....