bfg/doc
Composer 安装命令:
composer require bfg/doc
包简介
Php doc block generator
README 文档
README
A system for describing the behavior of classes where magic methods are used so as not to lose connection with the classes.
What is it for?
Its main purpose is to use it to describe your magic methods or properties that are accumulated in the properties of the class.
Install
composer require bfg/doc
Principle of operation
For a convenient description of properties, I wrote this logic on the attribute system that was added to php 8.
The kernel searches for files in all project folders,
except for the following: {base_path}/public, {base_path}/vendor,
{base_path}/routes, {base_path}/resources, {base_path}/storage,
{base_path}/runtimes, {base_path}/database.
And it ignores all named folders: node_modules, css, js.
Searches for files with the *.php extension and checks for
the existence of a class in the file.
To avoid difficulties, it is necessary to create a separate file for each class.
Usage
In total, for generating helpers, I created 2 main attributes:
/** * @props string $type Doc var type: "@method" * @props array|string|null $var_type Doc type of var * @props string|null $name Doc name of var * @props string|null $description Doc description of the var */ use Bfg\Doc\Attributes\Doc($type, $var_type, $name|null, $description|null);
The first attribute Bfg\Doc\Attributes\Doc is needed just to designate a property
that will extend the capabilities of the class.
/** * @props string $name Class namespace for mixin helper */ use Bfg\Doc\Attributes\DocClassName($name);
The second attribute Bfg\Doc\Attributes\DocClassName is needed to indicate the name of the class
into which these properties will be added.
This can be useful if you are making a package that can extend its properties as needed.
I also added several aliases for the Bfg\Doc\Attributes\Doc attribute:
// To generate method helpers use Bfg\Doc\Attributes\DocMethods($var_type, $name|null, $description|null); // To generate property helpers use Bfg\Doc\Attributes\DocProperties($var_type, $name|null, $description|null); // To generate method helpers from array use Bfg\Doc\Attributes\DocMethodsFromArray($var_type, $description|null); // To generate property helpers from array use Bfg\Doc\Attributes\DocPropertiesFromArray($var_type, $description|null);
Macro strings:
- Global:
- {name} - The name of variable
- Array:
- {key} - Key of array
- {value} - Value of array
- Variable:
- {value} - Value of variable
- {type} - Type of variable
- {value_construct} - The value class construct props
- Class name:
- {class} - The name of class
- {namespace} - The namespace of class
Example
use Bfg\Doc\Attributes\DocMethodsFromArray; use Bfg\Doc\Attributes\DocPropertiesFromArray; use Bfg\Doc\Attributes\DocClassName; /** * Class PropsData * * Result: * @method PropsData|static test() From inputs property for test method * @[type] [var_type] [name] [description] * @property-read PropsData $simple_form * @[type] [var_type] [name] * * And if you want you can add the "DocClassName" and created this class like mixin * @mixin \Bfg\Doc\Attributes\PropDataBlocks */ class PropsData { /** * @var array|string[] */ #[DocMethodsFromArray(['{value}', 'static'], 'From {name} property for {key} method')] static array $inputs = [ 'test' => PropsData::class ]; /** * @var array|string[] */ #[DocPropertiesFromArray] protected array $forms = [ 'simple_form' => PropsData::class ]; /** * @var array|string[] */ #[DocPropertiesFromArray, DocClassName('PropDataBlocks')] protected array $blocks = [ 'simple_block' => PropsData::class ]; }
Run
To start the generator, just call the artisan command:
php artisan make:docs
or
composer dump-autoload
bfg/doc 适用场景与选型建议
bfg/doc 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 60.41k 次下载、GitHub Stars 达 1, 最近一次更新时间为 2021 年 06 月 23 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「doc」 「block」 「laravel」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 bfg/doc 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 bfg/doc 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 bfg/doc 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Block routes by IP
See how Matrix and Neo blocks are being used across your sections.
Prevent crawlers from creating a session
A tool for display docs or api docs to others
This module is designed to provide a special alerts feed block for Howard University
This ConcreteCMS/concrete5 addon installs a block type that when added to a page allows you to redirect visitors to this page to another page that you specify or an external URL.
统计信息
- 总下载量: 60.41k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 16
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2021-06-23