PHP code example of timeax / ui-config-schema

1. Go to this page and download the library: Download timeax/ui-config-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/ */

    

timeax / ui-config-schema example snippets




use Timeax\ConfigSchema\Schema\ConfigField;
use Timeax\ConfigSchema\Schema\ConfigGroup;
use Timeax\ConfigSchema\Schema\UiConfigSchema;
use Timeax\ConfigSchema\Schema\ConfigOption;
use Timeax\ConfigSchema\Schema\ConfigTab;

$schema = new UiConfigSchema(
    settings: [
        'gateway' => new ConfigGroup(
            label: 'Gateway',
            tabs: ['payments'],
            children: [
                'public_key' => new ConfigField(
                    name: 'public_key',
                    label: 'Public Key',
                    rue,
            



$flat = $schema->flatten();

// ConfigSchema { fields: ConfigField[] }
// Each field may carry ->group (e.g. "gateway")



use Timeax\ConfigSchema\Schema\ConfigSchema;

/** @var ConfigSchema $flat */
$tree = $flat->toUiConfigSchema();



use Timeax\ConfigSchema\Support\ConfigBag;

$config = new ConfigBag(
    sandbox: true,
    options: [
        'mode' => 'card',
        'public_key' => 'pk_test_...',
    ],
    secrets: [
        'secret_key' => 'sk_test_...',
    ],
);

// secrets are excluded from jsonSerialize by default
$public = $config->jsonSerialize();



use Timeax\ConfigSchema\Support\ConfigValidationResult;

$result = ConfigValidationResult::fail()
    ->addError('public_key', 'Required')
    ->addError('secret_key', 'Required');

if (! $result->isOk()) {
    return $result->jsonSerialize();
}