Adrian
Adrian

Reputation: 547

How to modify a token in a text file?

I have 3 config files with a token like "[DBPASSWORD]" that I'd like to modify from my "build" task wiht Phing. I didn't find a task that performs what I need and before writing my own task for this I'd like to know if anyone has a better solution.

Thanks!

Upvotes: 1

Views: 911

Answers (1)

Adrian
Adrian

Reputation: 547

To answer to my own question, I finally did it like this. My conf file has this tokens:

user:     %%dbUser%%
password: %%dbPassword%%

I had to copy this file, config.yml.dist to config.yml, and change the tokens, so I did this:

<copy file="./config.yml.dist" tofile="./config.yml">
    <filterchain>
        <replacetokens begintoken="%%" endtoken="%%">
            <token key="dbUser" value="myUser" />
            <token key="dbPassword" value="myPassword" />
        </replacetokens>
    </filterchain>
</copy>

And thats it.

Upvotes: 5

Related Questions