PHP code example of friendsofhyperf / command-validation
1. Go to this page and download the library: Download friendsofhyperf/command-validation library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
friendsofhyperf / command-validation example snippets
declare(strict_types=1);
namespace App\Command;
use FriendsOfHyperf\CommandValidation\Traits\ValidatesInput;
use Hyperf\Command\Command as HyperfCommand;
use Hyperf\Command\Annotation\Command;
#[Command]
class FooCommand extends HyperfCommand
{
use ValidatesInput;
/**
* 执行的命令行
*/
protected string $name = 'foo:hello {?name : The name of the person to greet.}';
public function handle()
{
$this->info(sprintf('Hello %s.', $this->input->getArgument('name')));
}
protected function rules(): array
{
return [
'name' => '