Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/china-wangyu/php-reflex-core
原生PHP的reflex反射注释模型composer扩展
https://github.com/china-wangyu/php-reflex-core
Last synced: about 2 months ago
JSON representation
原生PHP的reflex反射注释模型composer扩展
- Host: GitHub
- URL: https://github.com/china-wangyu/php-reflex-core
- Owner: china-wangyu
- License: mit
- Created: 2019-05-02T13:22:47.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2020-06-14T11:17:56.000Z (over 4 years ago)
- Last Synced: 2024-08-08T17:42:50.500Z (5 months ago)
- Language: PHP
- Homepage: https://github.com/china-wangyu/php-reflex-core
- Size: 29.3 KB
- Stars: 5
- Watchers: 1
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# php-reflex-core
php 核心反射类封装# `composer` 安装
```composer
composer require wangyu/reflex-core
```# 使用方法
## 首先引入命名空间`use WangYu\Reflex`
```php
use WangYu\Reflex;
```## 获取对象反射实例
- 获取类反射实例
```php
$reflex = Reflex($object);
```- 获取类方法反射示例
```php
$reflex = Reflex($object);
$actionReflex = $reflex->setMethod($action);
```## 最后获取对应的方法反射文档数据
> 如果想获取下面的内容,方法的注释应当这样写
**`类注释举例:`**
```php
/**
* Class Book
* @route('v1/book')
* @package app\api\controller\v1
*/
class Book
{
}
```**`获取:`**
```php
$route = $reflex->get('route',['rule']);
```**`结果:`**
```php
$route = {
['rule' => '/v1/book/']
}
```**`方法注释举例:`**
```php
/**
* 查询指定bid的图书
* @route('v1/book/:bid','get')
* @param Request $bid
* @param('bid','bid的图书','require')
* @return mixed
*/
public function getBook($bid)
{
$result = BookModel::get($bid);
return $result;
}
```**`获取:`**
```php
$route = $actionReflex->get('route',['rule','method']);
```**`结果:`**
```php
$route = {
['rule' => '/v1/book/','method' => 'get']
}
```## 判断某个注解是否存在
**`方法注释举例:`**
```php
/**
* 查询指定bid的图书
* @route('v1/book/:bid','get')
* @param Request $bid
* @param('bid','bid的图书','require')
* @auth()
* @return mixed
*/
public function getBook($bid)
{
$result = BookModel::get($bid);
return $result;
}
```**`获取:`**
```php
$route = $actionReflex->isExist('auth');
```**`结果:`**
> 结果为true代表存在,为false代表不存在
```php
$route = true; # 代表存在
```# 联系我们
- QQ: `354007048`
- Email: `[email protected]`