1. Go to this page and download the library: Download browserfs/runtime 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/ */
// begin form validation ...
$age = isset( $_POST['age'] )
&& preg_match( '/^[\d]+$/', $_POST['age'] )
&& (int)$_POST['age'] > 20
? (int)$_POST['age']
: null;
$name = isset( $_POST['name'] )
&& strlen( $_POST['name'] ) > 0
&& preg_match( '/^[a-z\\s]{2,30}$/i', $_POST['name'] )
? $_POST['name']
: null;
if ( $age === null ) {
throw new Exception('Please submit a valid age!' );
}
if ( $name === null ) {
throw new Exception('Please submit a valid name, containing only letters and characters');
}
// end form parameters input validation ...
...
// load our types and validators into a object called "runtime".
$runtime = \browserfs\Runtime::create([
__DIR__ . '/defs/Webservices.defs',
..., // other definition file
...,
..., // other definition file
]);
$result = json_decode( $myWebServiceJSONResponse );
// if $result is validated by our validator called
// WebserviceResponse, then we're done, all fields
// are in their place as expected
if ( $runtime->isValidatableBy( $result, 'WebserviceResponse', $errors ) ) {
// good, webservice response is valid, everything's fine
$utilData = $result['data'];
} else {
// we've got errors:
print_r( $errors );
}
...
// load our types and validators into a object called "runtime".
$runtime = \browserfs\Runtime::create([
__DIR__ . '/defs/SampleRequest.type'
]);
if ( $runtime->isValidatableBy( $_POST, 'SamplePostRequest', $errors ) ) {
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.