手机浏览 RSS 2.0 订阅 膘叔的简单人生 , 腾讯云RDS购买 | 超便宜的Vultr , 注册 | 登陆
浏览模式: 标准 | 列表Tag:phing

phing的配置文件

 官网上有一份phing的基本配置文件,网上又找了一份比较复杂的,根据自己的项目对比一下喽

官网配置文件:
http://www.phing.info/docs/guide/stable/chapters/GettingStarted.html
  1. <?xml version="1.0" encoding="UTF-8"?>  
  2.   
  3. <project name="FooBar" default="dist">  
  4.   
  5.     <!-- ============================================  -->  
  6.     <!-- Target: prepare                               -->  
  7.     <!-- ============================================  -->  
  8.     <target name="prepare">  
  9.         <echo msg="Making directory ./build" />  
  10.         <mkdir dir="./build" />  
  11.     </target>  
  12.   
  13.     <!-- ============================================  -->  
  14.     <!-- Target: build                                 -->  
  15.     <!-- ============================================  -->  
  16.     <target name="build" depends="prepare">  
  17.         <echo msg="Copying files to build directory..." />  
  18.   
  19.         <echo msg="Copying ./about.php to ./build directory..." />  
  20.         <copy file="./about.php" tofile="./build/about.php" />  
  21.   
  22.         <echo msg="Copying ./browsers.php to ./build directory..." />  
  23.         <copy file="./browsers.php" tofile="./build/browsers.php" />  
  24.   
  25.         <echo msg="Copying ./contact.php to ./build directory..." />  
  26.         <copy file="./contact.php" tofile="./build/contact.php" />  
  27.     </target>  
  28.   
  29.     <!-- ============================================  -->  
  30.     <!-- (DEFAULT)  Target: dist                       -->   
  31.     <!-- ============================================  -->  
  32.     <target name="dist" depends="build">  
  33.         <echo msg="Creating archive..." />  
  34.   
  35.         <tar destfile="./build/build.tar.gz" compression="gzip">  
  36.             <fileset dir="./build">  
  37.                 <include name="*" />  
  38.             </fileset>  
  39.         </tar>  
  40.   
  41.         <echo msg="Files copied and compressed in build directory OK!" />  
  42.     </target>  
  43. </project>  
 
第三方配置文件 :
参考:https://gist.github.com/leric/1216551
  1. <?xml version="1.0" encoding="UTF-8"?>  
  2.    
  3. <project name="ucenter" default="deploy">  
  4.    
  5.     <!-- Target: config 设置变量,控制部署到不同环境-->  
  6.     <target name="config">  
  7.         <property name="svn_user" value="leric" />  
  8.         <property name="svn_pass" value="" />  
  9.         <input propertyname="deploy_env">Deploy to Env(prod|test):</input>  
  10.         <if>  
  11.             <equals arg1="${deploy_env}" arg2="prod" />  
  12.             <then>  
  13.                 <property name="project_home" value="/opt/www/ucenter" />  
  14.                 <property name="web_servers" value="www.ucenter.com,www2.ucenter.com" />  
  15.                 <property name="web_server_user" value="leric" />  
  16.                 <property name="web_server_pass" value="leric" />  
  17.             </then>  
  18.         </if>  
  19.         <if>  
  20.             <equals arg1="${deploy_env}" arg2="test" />  
  21.             <then>  
  22.                 <property name="project_home" value="/opt/www/ucenter" />  
  23.                 <property name="web_servers" value="127.0.0.1" />  
  24.                 <property name="web_server_user" value="root" />  
  25.                 <property name="web_server_pass" value="123456" />  
  26.             </then>  
  27.         </if>  
  28.     </target>  
  29.    
  30.     <!-- Target: build  Checkout from svn, and make tar.gz -->  
  31.     <target name="build" depends="config">  
  32.         <echo msg="Export code from svn..." />  
  33.         <input propertyname="export_revision">Revision to export from svn:</input>  
  34.         <svnupdate  
  35.            svnpath="svn"  
  36.            revision="${export_revision}"  
  37.            username="${svn_user}" password="${svn_pass}"  
  38.            nocache="true"  
  39.            todir="./"/>  
  40.    
  41.         <echo msg="Creating archive..." />  
  42.         <delete file="./dist.tar.gz" />  
  43.         <tar destfile="./dist.tar.gz" compression="gzip" prefix="rev_${export_revision}">  
  44.             <fileset dir="./" defaultexcludes="true">  
  45.                 <include name="**" />  
  46.                 <exclude name="**/.svn" />  
  47.             </fileset>  
  48.         </tar>  
  49.     </target>  
  50.    
  51.     <!-- Target: deploy   Upload tar.gz, switch to uploaded revision  -->  
  52.     <target name="deploy" depends="config,build">  
  53.         <foreach list="${web_servers}" param="web_server" target="deploy_one" />  
  54.     </target>  
  55.     <target name="deploy_one">  
  56.         <scp username="${web_server_user}" password="${web_server_pass}"  
  57.                 host="${web_server}" todir="${project_home}/revs"  
  58.                 file="./dist.tar.gz" />  
  59.    
  60.         <ssh username="${web_server_user}" password="${web_server_pass}"  
  61.                  host="${web_server}"  
  62.                  command="cd ${project_home}/revs; tar zxf dist.tar.gz; rm dist.tar.gz;" />  
  63.    
  64.         <ssh username="${web_server_user}" password="${web_server_pass}"  
  65.                  host="${web_server}"  
  66.                  command="rm -f ${project_home}/current; ln -s ${project_home}/revs/rev_${export_revision} ${project_home}/current" />  
  67.     </target>  
  68.       
  69.     <!-- Target: switch    Switch current revision  -->  
  70.     <target name="switch" depends="config">  
  71.         <foreach list="${web_servers}" param="web_server" target="switch_one" />  
  72.     </target>  
  73.     <target name="switch_one">  
  74.         <ssh username="${web_server_user}" password="${web_server_pass}"  
  75.              host="${web_server}"  
  76.              command="ls -al ${project_home}/revs" />  
  77.         <input propertyname="revision">Revision to set as active:</input>  
  78.         <ssh username="${web_server_user}" password="${web_server_pass}"  
  79.              host="${web_server}"  
  80.              command="rm -f ${project_home}/current; ln -s ${project_home}/revs/rev_${revision} ${project_home}/current" />   
  81.     </target>  
  82.       
  83.       
  84.     <!-- Target: update_deps  Update server setting by execute scripts(database, crontab, restart service, etc.)  -->  
  85.     <target name="update_deps" depends="config">  
  86.         <foreach list="${web_servers}" param="web_server" target="update_deps_one" />  
  87.     </target>  
  88.     <target name="update_deps_one">  
  89.         <ssh username="${web_server_user}" password="${web_server_pass}"  
  90.              host="${web_server}"  
  91.              command="cd ${project_home}/current; sudo cp crontab /etc/cron.d/ucenter" />  
  92.         <ssh username="${web_server_user}" password="${web_server_pass}"  
  93.              host="${web_server}"  
  94.              command="cd ${project_home}/current; php app/scripts/migration.php" />  
  95.         <input propertyname="confirm_sql">Confirm database migration sql script(yes|no):</input>  
  96.         <if>  
  97.             <equals arg1="${confirm_sql}" arg2="yes" />  
  98.             <then>  
  99.                 <ssh username="${web_server_user}" password="${web_server_pass}"  
  100.                      host="${web_server}"  
  101.                      command="cd ${project_home}/current; php app/scripts/migration.php execute" />  
  102.             </then>  
  103.         </if>  
  104.     </target>  
  105. </project>  
详细的文档还是看官方吧:http://www.phing.info/trac/wiki/Users/Documentation,我目前是在利用phpstorm的phing进行测试,但事实上还不如直接用命令行罢了,自从phpstorm升到6之后,对于一些可执行文件都开始用phar进行封装了。这是一件好事。
 
为了更好的使用phing,还是需要把文档看完的:http://www.phing.info/docs/guide/stable/,事实上phing在几年前就准备开始尝试了,但最终都没有正式在项目里使用。为了以后更好的管理和发布项目,想了想,还是先试一下。
事实上,我是想将一份代码分发到N台服务器,所以我最近在做不停的尝试。。。也考虑过用git进行分发,只是还没有开始罢了。估计下一步就会用git进行测试了

Tags: phing