Download the PHP package keygn/tp6-annotation without Composer
On this page you can find all versions of the php package keygn/tp6-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 tp6-annotation
think-annotation for ThinkPHP6
安装
composer require keygn/tp6-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
路由对象$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 tp6-annotation with dependencies
PHP Build Version
Package Version
Requires
topthink/framework Version
^6.0
doctrine/annotations Version ^1.6
php-di/phpdoc-reader Version ^2.1
php Version >=7.0
doctrine/annotations Version ^1.6
php-di/phpdoc-reader Version ^2.1
php Version >=7.0
The package keygn/tp6-annotation contains the following files
Loading the files please wait ....