# Configuring a variable in addon bundle.

**URL:** https://forum.mautic.org/t/configuring-a-variable-in-addon-bundle/1435
**Category:** Product Support
**Created:** [July 22, 2015, 7:39am UTC](https://forum.mautic.org/t/configuring-a-variable-in-addon-bundle/1435 "2015-07-22T07:39:39Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![kleand.12](https://avatars.discourse-cdn.com/v4/letter/k/3ec8ea/32.png) [@kleand.12](https://forum.mautic.org/u/kleand.12)
#### Post date: [July 22, 2015, 7:39am UTC](https://forum.mautic.org/t/configuring-a-variable-in-addon-bundle/1435/1 "2015-07-22T07:39:39Z")

</div>

Hello Mautic team!  
  
  
  
I am a good at PHP but junior at symfony and mautic. I have read articles and managed to create a new addOn bundle and set it up to work perfectly.  
  
In my folder I have MyBundleName/Config/config.php where I have written necessary array. Now I want to configure a constant variable to my bundle for ex: SOME\_TOKEN = “hardcoded” and access this variable in my bundle’s controller method. I tried to add a new key to config array like this:  
  
‘parameters’ =\> array(  
  
‘some\_token’ =\> ‘hardcoded’  
  
),  
  
  
  
and when I try to access it from controller like this: $this-\>container-\>getParameter(‘some\_token’) it generates a error log. This may be due to my poor info about symfony framework but as far as I read you have modified the framework.  
  
Thank you in advance!

---

<div class="post-metadata">

### Author: ![kleand.12](https://avatars.discourse-cdn.com/v4/letter/k/3ec8ea/32.png) [@kleand.12](https://forum.mautic.org/u/kleand.12)
#### Post date: [July 23, 2015, 7:19am UTC](https://forum.mautic.org/t/configuring-a-variable-in-addon-bundle/1435/2 "2015-07-23T07:19:35Z")

</div>

Hi Chad

Information you provided was very helpful!

Thank you very much for your support!

---

<div class="post-metadata">

### Author: ![chad.windnagle](https://avatars.discourse-cdn.com/v4/letter/c/7feea3/32.png) [@chad.windnagle](https://forum.mautic.org/u/chad.windnagle)
#### Post date: [July 22, 2015, 5:44pm UTC](https://forum.mautic.org/t/configuring-a-variable-in-addon-bundle/1435/3 "2015-07-22T17:44:35Z")

</div>

Hi Kleand

To access those parameters you have to use a special factory get function:

[https://github.com/mautic/mautic/blob/staging/app/bundles/CoreBundle/Factory/MauticFactory.php#L725-L754](https://github.com/mautic/mautic/blob/staging/app/bundles/CoreBundle/Factory/MauticFactory.php#L725-L754)

> [@](#):
>
> $this-\>factory-\>getBundleConfig(‘addonName’, ‘configKey’, true)

You’ll want to use the ‘incudeAddonss’ flag to true so that it gets it properly. And you’ll need to use the factory service to call up to the factory.

There’s detailed info on how to use factory here:  
[http://mautic.github.io/developer-documentation/#factory-service](http://mautic.github.io/developer-documentation/#factory-service)

---

<div class="post-metadata">

### Author: ![kleand.12](https://avatars.discourse-cdn.com/v4/letter/k/3ec8ea/32.png) [@kleand.12](https://forum.mautic.org/u/kleand.12)
#### Post date: [July 22, 2015, 7:39am UTC](https://forum.mautic.org/t/configuring-a-variable-in-addon-bundle/1435/4 "2015-07-22T07:39:39Z")

</div>

Hello Mautic team!

I am a good at PHP but junior at symfony and mautic. I have read articles and managed to create a new addOn bundle and set it up to work perfectly.  
In my folder I have MyBundleName/Config/config.php where I have written necessary array. Now I want to configure a constant variable to my bundle for ex: SOME\_TOKEN = “hardcoded” and access this variable in my bundle’s controller method. I tried to add a new key to config array like this:  
‘parameters’ =\> array(  
‘some\_token’ =\> ‘hardcoded’  
),

and when I try to access it from controller like this: $this-\>container-\>getParameter(‘some\_token’) it generates a error log. This may be due to my poor info about symfony framework but as far as I read you have modified the framework.  
Thank you in advance!

---

<div class="post-metadata">

### Author: ![silavapi](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/silavapi/32/7424_2.png) [@silavapi](https://forum.mautic.org/u/silavapi)
#### Post date: [February 2, 2020, 10:59pm UTC](https://forum.mautic.org/t/configuring-a-variable-in-addon-bundle/1435/5 "2020-02-02T22:59:09Z")

</div>


