Extend your .properties files while using Phing
@shakedko
IF AN EXPERT SAYS IT CAN'T BE DONE GET ANOTHER EXPERT.
- DAVID BEN-GURION

Extend your .properties files while using Phing

Description

First, those of you which don"t know Phing I suggest to take a quick look at theirย website

For sometime I was hoping to get into writing this small task so I would be able to decouple some un-useful code\configuration.

One of the problems when using Phing and it"s .properties file is that you have to rewrite your configuration when using more than one configuration file.

Suggested Solution

I have added a new task for Phing and a new Properties class:

  1. PropertiesFileTask.php -the task itself uses PropertiesFile class instead of the base Properties class.
  2. PropertiesFile.php- checks if the .propertiesfile extends another file and load it recursively.

Full code may be found at my [Github repository](https://github.com/Shaked/PhingExtendedProperties "Shaked"s Github repository ")

Example:

[Shaked] >> phing build.xml
Buildfile: /var/www/html/phingextendedproperties/build.xml

Environment please [dev] ?

dev:

[propertiesfile] Loading
/var/www/html/phingextendedproperties/properties/dev.properties

build > default:

 [echo]
            You are using "dev"
            Dummy is:
                    "dummy1"
                    "dummy2"
                    "dummy3"
            Enjoy!
BUILD FINISHED
Total time: 1 minutes  23.49 seconds

stage:

[propertiesfile] Loading
/var/www/html/phingextendedproperties/properties/stage.properties

build > default:

 [echo]
            You are using "stage"
            Dummy is:
                    ${application.dummy1}
                    "dummy2"
                    "dummy3"
            Enjoy!
BUILD FINISHED

Total time: 1.0277 second

prod:

[propertiesfile] Loading
/var/www/html/phingextendedproperties/properties/prod.properties

build > default:

 [echo]
            You are using "prod"
            Dummy is:
                    ${application.dummy1}
                    ${application.dummy2}
                    "dummy3"
            Enjoy!
BUILD FINISHED
Total time: 8.7317 seconds

Please share your opinion and thoughts about the solution or about other ways to solve this issue.

ย 

Shak

Work In Progress ๐Ÿšง
Discipline