PHP code example of effiana / config-bundle

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

    

effiana / config-bundle example snippets


// in app/AppKernel.php
public function registerBundles() {
	$bundles = [
		// ...
		new Effiana\ConfigBundle\EffianaConfigBundle(),
	];
	// ...
}

$this->get('effiana_config')->get('name-of-a-setting')

$this->get('effiana_config')->all()

$this->get('effiana_config')->getBySection('name-of-a-section')

$this->get('effiana_config')->set('name-of-a-setting', 'new value');
$this->get('effiana_config')->setMultiple(['setting-1' => 'foo', 'setting-2' => 'bar']);

// src/MyCompany/MyBundle/Entity/MySetting.php
use Effiana\ConfigBundle\Entity\BaseSetting;
use Doctrine\ORM\Mapping as ORM;

/**
 * @ORM\Entity(repositoryClass="Effiana\ConfigBundle\Repository\SettingRepository")
 * @ORM\Table(name="my_setting")
 */
class MySetting extends BaseSetting {

	/**
	 * @var string|null
	 * @ORM\Column(name="value", type="text", nullable=true)
	 */
	protected $value;

	/**
	 * @var string|null
	 * @ORM\Column(name="comment", type="string", nullable=true)
	 */
	protected $comment;

	public function setComment($comment) {
		$this->comment = $comment;
	}

	public function getComment() {
		return $this->comment;
	}

}
sh
# in a shell
php bin/console doctrine:migrations:diff
php bin/console doctrine:migrations:migrate