Zend Framework

constants in xml config file

Details

  • Type: Bug Bug
  • Status: Resolved Resolved
  • Priority: Major Major
  • Resolution: Fixed
  • Affects Version/s: 1.8.0
  • Fix Version/s: 1.9.0
  • Component/s: Zend_Config
  • Labels:
    None

Description

Its its not possible to use constants in the config xml, for example APPLICATION_PATH, to configure for example resources

for example this works in ini files:

bootstrap.path = APPLICATION_PATH "/Bootstrap.php"

but in config xml it doesnt

<bootstrap>
<path>APPLICATION_PATH "/Bootstrap.php"</path>
</bootstrap>

  1. patch.patch
    12/Jun/09 12:50 PM
    3 kB
    julien PAULI
  2. ZF-6960-partly.patch
    16/Jun/09 7:20 AM
    4 kB
    Ben Scholzen

Activity

Hide
Florent Cailhol added a comment -

Actualy, when using an ini file, parse_ini_file() is used. This function handles PHP constants contrary to simplexml_load_file() which does not.
In order to add the constant support in Zend_Application when using xml files, Zend_Config_Xml must be rewrite.

Show
Florent Cailhol added a comment - Actualy, when using an ini file, parse_ini_file() is used. This function handles PHP constants contrary to simplexml_load_file() which does not. In order to add the constant support in Zend_Application when using xml files, Zend_Config_Xml must be rewrite.
Hide
julien PAULI added a comment -

That patch could make it.
Let's Rob review it

Show
julien PAULI added a comment - That patch could make it. Let's Rob review it
Hide
julien PAULI added a comment -

Mind there is a typo in the patch , replace $this->_parseXMl() by $this->_parseXmlForPHPConstants() ; forgot to rename it.

Show
julien PAULI added a comment - Mind there is a typo in the patch , replace $this->_parseXMl() by $this->_parseXmlForPHPConstants() ; forgot to rename it.
Hide
Rob Allen added a comment - - edited

Will have a look soon. Ping me if I don't come back within a week!

Update: looked!

Problem with patch is that it doesn't prevent constants in tag names and doesn't seem to handle concatenating constants within a string.

Show
Rob Allen added a comment - - edited Will have a look soon. Ping me if I don't come back within a week! Update: looked! Problem with patch is that it doesn't prevent constants in tag names and doesn't seem to handle concatenating constants within a string.
Hide
Ben Scholzen added a comment - - edited

Imho that's not the way to go. I spoke with SpotSec about it already, and we think that you should include a namespace for inserting constants, so for example:

<bootstrap>
    <path><zf:const zf:name="APPLICATION_PATH"/>/Bootstrap.php</path>
</bootstrap>
Show
Ben Scholzen added a comment - - edited Imho that's not the way to go. I spoke with SpotSec about it already, and we think that you should include a namespace for inserting constants, so for example:
<bootstrap>
    <path><zf:const zf:name="APPLICATION_PATH"/>/Bootstrap.php</path>
</bootstrap>
Hide
Ryan Mauger added a comment -

+1 for Bens suggestion.

This could also be used for further features later, such as XML includes (if it is decided to support them), and would add a consistend interface for such things.

Show
Ryan Mauger added a comment - +1 for Bens suggestion. This could also be used for further features later, such as XML includes (if it is decided to support them), and would add a consistend interface for such things.
Hide
Rob Allen added a comment - - edited

I quite like Ben & SpotSec's proposal on the grounds that it is completely backwards compatible.

Also, we should put extends within the namespace for the future and check with Matthew about the namespace to use.

Finally, I'd like to see the patch

Show
Rob Allen added a comment - - edited I quite like Ben & SpotSec's proposal on the grounds that it is completely backwards compatible. Also, we should put extends within the namespace for the future and check with Matthew about the namespace to use. Finally, I'd like to see the patch
Hide
Ben Scholzen added a comment -

Partly patch to fix the issue. Not all unit tests included yet, no support for namespace:extends, no documentation. Will be finished and comitted to trunk after Rob reviewed it.

Show
Ben Scholzen added a comment - Partly patch to fix the issue. Not all unit tests included yet, no support for namespace:extends, no documentation. Will be finished and comitted to trunk after Rob reviewed it.
Hide
Rob Allen added a comment -

Patch looks okay to me.

Have pinged Matthew to a-okay the concept and URI before we go ahead and implement.

Show
Rob Allen added a comment - Patch looks okay to me. Have pinged Matthew to a-okay the concept and URI before we go ahead and implement.
Hide
Geoffrey Tran added a comment -

A namespace would simply be "http://framework.zend.com/Zend/Config" etc..., but it might be nice if "zf" was the default

<bootstrap xmlns:foo="http://framework.zend.com/Zend/Config">
<path><foo:const /></path,>
</bootstrap>

Show
Geoffrey Tran added a comment - A namespace would simply be "http://framework.zend.com/Zend/Config" etc..., but it might be nice if "zf" was the default <bootstrap xmlns:foo="http://framework.zend.com/Zend/Config"> <path><foo:const /></path,> </bootstrap>
Hide
Lex Viatkin added a comment -

"Now, create your configuration. For this tutorial, we will use an INI style configuration; you may, of course, use an XML or PHP configuration file as well."

Please, remove this part from documentation until this issue will be fixed. I spent 1 hour to find out "why my XML config doesnt work.. they say it have!"

http://framework.zend.com/manual/en/zend.application.quick-start.html

Show
Lex Viatkin added a comment - "Now, create your configuration. For this tutorial, we will use an INI style configuration; you may, of course, use an XML or PHP configuration file as well." Please, remove this part from documentation until this issue will be fixed. I spent 1 hour to find out "why my XML config doesnt work.. they say it have!" http://framework.zend.com/manual/en/zend.application.quick-start.html
Hide
Aron Rotteveel added a comment -

Is there any ETA on when this feature will be released? I just discovered about this and would definately like to see this happening soon.

Show
Aron Rotteveel added a comment - Is there any ETA on when this feature will be released? I just discovered about this and would definately like to see this happening soon.
Hide
Ben Scholzen added a comment -

I'm waiting for Matthew's okay and will then finish it.

Show
Ben Scholzen added a comment - I'm waiting for Matthew's okay and will then finish it.
Hide
Rob Allen added a comment -

For reference, resolved in svn 16924

Show
Rob Allen added a comment - For reference, resolved in svn 16924
Hide
Weber Chris added a comment -

Thx a lot for resolving this issue, great job!

Show
Weber Chris added a comment - Thx a lot for resolving this issue, great job!

People

Vote (2)
Watch (6)

Dates

  • Created:
    Updated:
    Resolved: