3
votes

I'm currently working in a personal project using Zend Framework. I haven't been able to obtain good search results, nor asking my fellow coworkers :-/.

I use a lot of Ant / Phing at work and you have something called "properties files", they have this really cool feature: if you define a property inside the property file, then you could use it as a variable inside the same file to define other properties values i.e:

property1 = "apples"
property2 = "oranges"
property3 = "I really love ${property1} and ${property2}

So the expected result when using property3 will be "I really love apples and oranges".

I was wondering if there is such functionality available for ini files. I know that I can use constants inside ini files, but I don't really like to define constants using if/else to check the environment, but if you have a nicer way to do it this is basically what I will like to do:

[production]
public_path = 
external_path1 = ${public_path} "/a/url/to/something/"
external_path2 = ${public_path} "/another/url"

[development : production]
public_path = "/my_proyect/"
1
check my ans stackoverflow.com/questions/10408978/… not exactly what you want but does same work in the end. - Mr Coder
Your answer seems to not be working for me... I can see that constants are defined correctly but they are not replaced when I get the value from Zend_Config - ggarcia24
you don't need to get value through Zend_Config , use constants as they are used e.g use PUBLIC_PATH as it is where its required - Mr Coder

1 Answers

0
votes

You just can't use variables in your configuration values - except the constants as you noted yourself.