# Dynamically written constants

**URL:** <https://discourse.cakephp.org/t/dynamically-written-constants/1636>\
**Category:** Need Help\
**Created:** [November 30, 2016, 9:02am UTC](https://discourse.cakephp.org/t/dynamically-written-constants/1636 "2016-11-30T09:02:18Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![6120](https://avatars.discourse-cdn.com/v4/letter/6/278dde/32.png) [@6120](https://discourse.cakephp.org/u/6120)\
**Post date:** [November 30, 2016, 9:02am UTC](https://discourse.cakephp.org/t/dynamically-written-constants/1636/1 "2016-11-30T09:02:18Z")

</div>

There are things in companies sites that never change (name of a society, facebook link, address …).  
So I would like to be able to save those things as constants each time I initiate a new site in my cms (cakephp 3.x).  
So users can easily add their facebook link by typing something like [FACEBOOK] in any page.  
Until now, I hard coded those parameters in a custom bootstrap file (with configure::write() ) but I would like to be able to write them through a form.  
Is there a way to do this ? (I personally did not find)

---

<div class="post-metadata">

**Author:** ![Xoubaman](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/xoubaman/32/102_2.png) [@Xoubaman](https://discourse.cakephp.org/u/Xoubaman)\
**Post date:** [December 1, 2016, 8:20am UTC](https://discourse.cakephp.org/t/dynamically-written-constants/1636/2 "2016-12-01T08:20:21Z")

</div>

If you want them to be dynamic you will have to somehow store them, either in database, filesystem,…

If the idea is to read them from constants or using Configure::read(), maybe you can generate a .php file that you load in, for example, your bootstrap.

Or use database and then use some cache strategy to avoid querying for the same values every time.

Not a Cake related question at all but a general one.

---

<div class="post-metadata">

**Author:** ![6120](https://avatars.discourse-cdn.com/v4/letter/6/278dde/32.png) [@6120](https://discourse.cakephp.org/u/6120)\
**Post date:** [December 1, 2016, 9:38am UTC](https://discourse.cakephp.org/t/dynamically-written-constants/1636/3 "2016-12-01T09:38:59Z")

</div>

Thank you for your answer.

> [@Xoubaman](#):
>
> Not a Cake related question …

I know how to to that right in php. I just wanted to know if there was a better cakephp way.

Thank you again.

---

<div class="post-metadata">

**Author:** ![Graziel](https://avatars.discourse-cdn.com/v4/letter/g/71c47a/32.png) [@Graziel](https://discourse.cakephp.org/u/Graziel)\
**Post date:** [December 1, 2016, 10:02am UTC](https://discourse.cakephp.org/t/dynamically-written-constants/1636/4 "2016-12-01T10:02:20Z")

</div>

maybe something like [https://github.com/cakemanager/cakephp-settings](https://github.com/cakemanager/cakephp-settings)

---

<div class="post-metadata">

**Author:** ![6120](https://avatars.discourse-cdn.com/v4/letter/6/278dde/32.png) [@6120](https://discourse.cakephp.org/u/6120)\
**Post date:** [December 1, 2016, 4:03pm UTC](https://discourse.cakephp.org/t/dynamically-written-constants/1636/5 "2016-12-01T16:03:31Z")

</div>

Not really what I was looking for but very interesting.  
Thank you for this link.
