PHP code example of temant / settings-manager

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

    

temant / settings-manager example snippets


use Temant\SettingsManager\SettingsManager;
use Temant\SettingsManager\Enum\SettingType;
use Doctrine\ORM\EntityManagerInterface;

// Create a SettingsManager instance with Doctrine EntityManager
$settingsManager = new SettingsManager($entityManager);

// Add or update a setting
$settingsManager->set('site_name', 'My Awesome Site', SettingType::STRING);

// Retrieve a setting
$siteName = $settingsManager->get('site_name')->getValue();
echo $siteName; // Outputs 'My Awesome Site'

// Remove a setting
$settingsManager->remove('site_name');

use Temant\SettingsManager\Utils\SettingsExporter;

$jsonData = SettingsExporter::toJson($settingsManager);
echo $jsonData;

use Temant\SettingsManager\Utils\SettingsImporter;

$jsonData = '{"site_name": {"name": "site_name", "value": "My Awesome Site", "type": "STRING"}}';
SettingsImporter::fromJson($settingsManager, $jsonData);