find replace text in file with Phing

后端 未结 6 1060
误落风尘
误落风尘 2021-02-04 06:10

Does anyone know how to find and replace text inside a file with Phing?

6条回答
  •  孤独总比滥情好
    2021-02-04 06:23

    You can replace text inside files using filters. Filters are used inside other file operation tasks such as copy.

    I believe the main idea behind filters is that you can have template files with tokens instead of real values and you then substitute the tokens as a part of the copy process.

    Quick example: have a database configuration template file stored in a template directory. Then you copy it to the target configuration file using:

    
                    
                        
                            
                            
                            
                            
                            
                            
                        
                    
                
    

    There are plenty of other filters (e.g. regex search and replace) available. See more about filters in the documentation: http://phing.info/docs/guide/stable/chapters/appendixes/AppendixD2-CoreFilters.html

提交回复
热议问题