Generate PHPDoc properties automatically based on the rules specification of the FormRequest class
aharisu/generate-form-request-phpdoc is a Laravel package for generate phpdoc properties automatically based on the rules specification of the formrequest class.
It currently has 1 GitHub stars and 2.396 downloads on Packagist (latest version 0.3.1).
Install it with composer require aharisu/generate-form-request-phpdoc.
Discover more Laravel packages by aharisu
or browse all Laravel packages to compare alternatives.
Last updated
Generate PHPDoc properties automatically based on the rules specification of the FormRequest class.
composer require --dev aharisu/generate-form-request-phpdoc
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).
<?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 {}
}
--write Write PHPDoc directly to your FormRequest fileYou 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
php artisan vendor:publish --provider="aharisu\GenerateFormRequestPHPDoc\GenerateFormRequestPhpdocServiceProvider"
You can change some behaviors in config/generate-form-request-phpdoc.php.
Apache 2.0 & MIT