1. Go to this page and download the library: Download north/schema 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/ */
north / schema example snippets
use North\Schema\Schema;
$schema = new Schema([
'name' => 'string',
'age' => 'int',
]);
// validate input against schema.
// returns bool or throws exception.
$schema->valid([
'name' => 'fredrik',
'age' => 27,
]);
use North\Schema\Schema;
class User
{
public $name = '';
public function __construct($o)
{
foreach ($o as $k => $v) {
$this->$k = $v;
}
}
}
$schema = new Schema([
'name' => 'string',
]);
// validate input against schema.
// returns bool or throws exception.
$schema->valid(
new User([
'name' => 'fredrik',
]),
);