PHP code example of imatic / config-bundle

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

    

imatic / config-bundle example snippets


// in config/bundles.php
return [
    // ...
    Imatic\Bundle\ConfigBundle\ImaticConfigBundle::class => ['all' => true],
];

// src/Entity/Config.php


declare(strict_types=1);

namespace App\Entity;

use Doctrine\ORM\Mapping as ORM;

/**
 * @ORM\Entity
 */
class Config extends \Imatic\Bundle\ConfigBundle\Entity\Config
{
}

// src/Config/ConfigProvider.php
namespace App\Config;

use Imatic\Bundle\ConfigBundle\Provider\Definition;
use Imatic\Bundle\ConfigBundle\Provider\ProviderInterface;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Validator\Constraints as Assert;

final class ConfigProvider implements ProviderInterface
{
    public function getDefinitions(): array
    {
        return [
            new Definition('value', TextType::class, [
                'constraints' => [
                    new Assert\NotBlank(),
                ],
            ]),
        ];
    }
}

// src/Controller/ConfigController.php
namespace App\Controller;

use Imatic\Bundle\ConfigBundle\Config\ConfigManagerInterface;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;

final class ConfigController extends AbstractController
{
    public function getConfig(ConfigManagerInterface $config)
    {
        $value = $config->getValue('config.value');
        // ...
    }
}