PHP code example of gexingw / lumen-request-validator
1. Go to this page and download the library: Download gexingw/lumen-request-validator 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/ */
gexingw / lumen-request-validator example snippets
use Illuminate\Http\Request;
class IndexController
{
public function index(Request $request){
$rules = $messages = $attributes = [];
// 校验
$this->validate($request, $rules, $messages, $attributes);
}
}
use \GeXingW\LumenValidator\Request\ValidatorRequest;
class IndexRequest extends ValidatorRequest{
// Rules
protected function _rules()
{
$rules = [];
return $rules;
}
// Messages
protected function _messages()
{
$messages = [];
return $messages;
}
// Attributes
protected function _attributes()
{
$_attributes = [];
return $_attributes;
}
}
// Contorller
class IndexController
{
public function index(IndexRequest $request) // 依赖注入的方式
{
return 'Index controller';
}
}