PHP code example of domtomproject / easy-rest-bundle

1. Go to this page and download the library: Download domtomproject/easy-rest-bundle 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/ */

    

domtomproject / easy-rest-bundle example snippets


/* static version */
use Respect\Validation\Validator as v; return array (
  'default' => 
  array (
    'name' => v::notEmpty()->stringType(),
    'age' => v::notEmpty()->intType(),
    'sex' => v::notEmpty()->in(["male", "female"]),
    'language_with_skill' => v::keySet(v::key("pl", v::in(["intermediate", "basic", "none", "national"])), v::key("en", v::in(["intermediate", "basic", "none", "national"]))),
  ),
);

/* 'new' version, used for caching (because it's little bit faster) */
use Respect\Validation\Rules; return array (
  'default' => 
  array (
    'name' => new Rules\AllOf(new Rules\NotEmpty(), new Rules\StringType()),
    'age' => new Rules\AllOf(new Rules\NotEmpty(), new Rules\IntType()),
    'sex' => new Rules\AllOf(new Rules\NotEmpty(), new Rules\In(["male", "female"])),
    'language_with_skill' => new Rules\AllOf(new Rules\KeySet(new Rules\Key("pl", new Rules\In(["intermediate", "basic", "none", "national"])), new Rules\Key("en", new Rules\In(["intermediate", "basic", "none", "national"])))),
  ),
);