Contenu connexe Similaire à Write php deploy everywhere tek11 (20) Plus de Michelangelo van Dam (20) Write php deploy everywhere tek1120. Phing
•- build tool written in PHP
comparable to ANT
- but written in PHP :-)
• impressive list of task templates
• extensible for missing tasks
23. Export from SVN
<property name="buildpath" value="./build"/>
<property name="repopath"
value="https://svn.myserver.com/demo/trunk"/>
<target name="prepare">
<delete dir="${buildpath}"
includeemptydirs="true"
quiet="true"
verbose="false"
failonerror="false" />
<mkdir dir="${buildpath}"/>
</target>
<target name="getsources" depends="prepare">
<svnexport svnpath="/usr/bin/svn"
force="true"
nocache="true"
repositoryurl="${repopath}"
todir="${buildpath}"/>
</target>
28. Where to deploy to?
• bare metal servers
•- virtual servers
even cloud instances
• any OS (Windows, OSX, Linux, i5, …)
33. Deploy to windows
<target name="deploy-windows" depends="version-bugfix">
<ftpdeploy host="${env.win-prod}"
port="21"
username="${auth.win-prod.username}"
password="${auth.win-prod.password}"
dir="/"
mode="binary"
clearfirst="false">
<fileset dir=".">
<exclude=”./library/Zend”/>
<exclude=”./library/ZendX”/>
</fileset>
</ftpdeploy>
</target>
34. Deploy to S3
<target name="deploy-windows" depends="version-bugfix">
<ftpdeploy host="${env.win-prod}"
port="21"
username="${auth.win-prod.username}"
password="${auth.win-prod.password}"
dir="/"
mode="binary"
clearfirst="false">
<fileset dir=".">
<exclude=”./library/Zend”/>
<exclude=”./library/ZendX”/>
</fileset>
</ftpdeploy>
</target>
36. A few remarks
•- runs only on windows
but still uses phing :-)
• takes a considerable time to upload
• instances are defined in the config
37. Setting properties
<property
name="cmd-cspack"
value="c:Program FilesWindows Azure SDKv1.3bin
cspack.exe"
override="false"/>
<property
name="cmd-csrun"
value="c:Program FilesWindows Azure SDKv1.3bin
csrun.exe"
override="false"/>
38. Prepare for Azure
<target name="prepare-azure" depends="version-bugfix">
<!-- start building in ./bldtmp -->
<mkdir dir="./bldtmp" />
<copy todir="./bldtmp" overwrite="true">
<fileset dir="./deploy/azure">
<include name="**/*.*" />
</fileset>
</copy>
<copy todir="./bldtmp/PhpOnAzure.Web" overwrite="true">
<fileset dir=".">
<include name="**/*"/>
<include name="*"/>
</fileset>
</copy>
</target>
39. Deploy to Azure
<target name="deploy-azure" depends="prepare-azure">
<exec command=""${cmd-cspack}"
ServiceDefinition.csdef /
role:PhpOnAzure.Web;PhpOnAzure.Web /out:PhpAzure.cspkg"
dir="./bldtmp" />
<mkdir dir="./release/${phing.project.name}-$
{version.number}/azure-prod" />
<copy todir="./release/${phing.project.name}-$
{version.number}/azure-prod" overwrite="true">
<fileset dir="./bldtmp">
<include name="PhpOnAzure.cspkg"/>
<include name="ServiceConfiguration.cscfg"/>
</fileset>
</copy>
</target>
45. With CI
• always “ready to deploy” codebase
• feedback on quality
• documentation
• more …
47. Some reminders
•- design your apps to work everywhere
use OOP abstraction layers
- use plugins
- take care of sessions!
• investigate “the other platform”
- gives you a head start over competetion
- teaches you the caveats
• “cloud” solutions are in high-demand
- see what works best for your customer
53. Thank you
• source code:
http://github.com/DragonBe/zftest
• your rating:
http://joind.in/3438
•- follow me:
twitter: @DragonBe
- facebook: DragonBe
Please use joind.in for feedback