PHP code example of hexanet / settings-bundle

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

    

hexanet / settings-bundle example snippets



// app/AppKernel.php

// ...
class AppKernel extends Kernel
{
    public function registerBundles()
    {
        $bundles = array(
            // ...
            new Hexanet\SettingsBundle\HexanetSettingsBundle(),
        );

        // ...
    }

    // ...
}



namespace App\Settings\AppSchema;

use Hexanet\SettingsBundle\Schema\SettingsBuilder;
use Hexanet\SettingsBundle\Schema\SchemaInterface;

class AppSchema implements SchemaInterface
{
    public function build(SettingsBuilder $settingsBuilder): void
    {
        $settingsBuilder->addSetting('itemsPerPage', 25);
    }
}

public function indexAction(SettinsManagerInterface $settingsManager) {
    // set and get
    $settingsManager->set('tva', 19.6);
    $settingsManager->get('tva');

    // check if settign exists
    $settingsManager->has('tva');

    // get all settings
    $settingsManager->all();

    // retrieve a non-existent setting 
    $settingsManager->get('not here');
    //  SettingNotFoundException is throw
}