1. Go to this page and download the library: Download craue/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/ */
// in src/Controller/MyController.php
use Craue\ConfigBundle\Util\Config;
public function indexAction(Config $config) {
// use $config
}
// in src/Controller/MyController.php
use Craue\ConfigBundle\Util\Config;
public function indexAction() {
// use $this->get('craue_config')
}
public static function getSubscribedServices() {
return array_merge(parent::getSubscribedServices(), [
'craue_config' => Config::class,
]);
}
// src/MyCompany/MyBundle/Entity/MySetting.php
use Craue\ConfigBundle\Entity\BaseSetting;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity(repositoryClass="Craue\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
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.