定制 aharisu/generate-form-request-phpdoc 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

aharisu/generate-form-request-phpdoc

最新稳定版本:0.3.1

Composer 安装命令:

composer require aharisu/generate-form-request-phpdoc

包简介

Generate PHPDoc properties automatically based on the rules specification of the FormRequest class

README 文档

README

Generate PHPDoc properties automatically based on the rules specification of the FormRequest class.

Installation

composer require --dev aharisu/generate-form-request-phpdoc

Usage

php artisan form-request:generate

Outputs the PHPDoc of the classes inheriting from FormRequest in the app/Http/Requests directory to an external file (e.g. _form_request_phpdoc.php).

For example

<?php

namespace App\Http\Requests;

use Illuminate\Foundation\Http\FormRequest;

class FooRequest extends FormRequest
{
    public function rules()
    {
        return [
            'id' => ["required", "integer"],
            'int_value' => ["nullable", "integer"],
            'numeric_value' => ["required", "numeric"],
            'string_value' => ["required", "string"],
            'bool_value' => ["nullable", "boolean"],
            'json_value' => ["required", "json"],
            'indexed_array' => ["required", "array"],
            'indexed_array.*' => ["required", "string"],
            'shaped_array' => ["nullable", "array"],
            'shaped_array.id' => ["required", "int"],
            'shaped_array.name' => ["required", "string"],
            'shaped_array.thumbnail' => ["nullable", "file"],
        ];
    }
}
namespace App\Http\Requests {
/**
 * @property-read int $id
 * @property-read ?int $int_value
 * @property-read int|float $numeric_value
 * @property-read string $string_value
 * @property-read ?bool $bool_value
 * @property-read mixed $json_value
 * @property-read string[] $indexed_array
 * @property-read ?array{id: int, name: string, thumbnail: ?\Illuminate\Http\UploadedFile} $shaped_array
 */
class FooRequest extends \Illuminate\Foundation\Http\FormRequest {}
}

Arguments

  • --write Write PHPDoc directly to your FormRequest file

Target specification

You can specify the output target by the class name with namespace or the file path.

php artisan form-request:generate App\Http\Requests\FooRequest
php artisan form-request:generate app/Http/Requests/FooRequest.php

Multiple specifications are also possible.

php artisan form-request:generate App\Http\Requests\FooRequest app/Http/Requests/BarRequest.php

Other settings

php artisan vendor:publish --provider="aharisu\GenerateFormRequestPHPDoc\GenerateFormRequestPhpdocServiceProvider"

You can change some behaviors in config/generate-form-request-phpdoc.php.

License

Apache 2.0 & MIT

统计信息

  • 总下载量: 2.39k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: Apache-2.0
  • 更新时间: 2023-04-12