1. Go to this page and download the library: Download xu767142206/x-validated 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/ */
use XValidated\Annotation\Rule;
use XValidated\ValidatedData;
class LoginDto extends ValidatedData
{
#[Rule(values: ["])]
public string $password;
}
use XValidated\Annotation\Validated;
use App\Model\LoginDto;
use Hyperf\HttpServer\Annotation\AutoController;
use Hyperf\HttpServer\Annotation\RequestMapping;
use Hyperf\HttpServer\Contract\RequestInterface;
#[AutoController]
class IndexController extends AbstractController
{
#[RequestMapping(path: "index", methods: "get,post")]
#[Validated]
public function index(RequestInterface $request, LoginDto $loginDto)
{
var_dump($loginDto->toArray());
return [
'param' => $request->getServerParams(),
];
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.