putting "phings" together - how to automate your life
TRANSCRIPT
![Page 1: Putting "Phings" together - how to automate your life](https://reader035.vdocuments.us/reader035/viewer/2022062404/554cb4d5b4c905335b8b4e5a/html5/thumbnails/1.jpg)
Putting "Phings" together - how to automate your life
![Page 2: Putting "Phings" together - how to automate your life](https://reader035.vdocuments.us/reader035/viewer/2022062404/554cb4d5b4c905335b8b4e5a/html5/thumbnails/2.jpg)
Table of contents
• About me• Introduction to Phing• Basics• What Phing can do for you• Phing and Drupal• How Phing is helping us/Demo• Conclusions• Q/A
![Page 3: Putting "Phings" together - how to automate your life](https://reader035.vdocuments.us/reader035/viewer/2022062404/554cb4d5b4c905335b8b4e5a/html5/thumbnails/3.jpg)
About me
• Boyan Borisov• Team Leader @
Propeople• [email protected]• @boyan_borisov• Skype: boian.borisov• http://linkedin.com/in/
boyanborisov
![Page 4: Putting "Phings" together - how to automate your life](https://reader035.vdocuments.us/reader035/viewer/2022062404/554cb4d5b4c905335b8b4e5a/html5/thumbnails/4.jpg)
What is Phing?• (PH)ing (I)s (N)ot (G)NU make• Project build tool• Platform-independent: works
on UNIX, Windows, Mac OSX• Based on Apache Ant• Provides a simple OO model
for extending• Uses XML build files• No required external
dependencies• Open source – written on
PHP5
![Page 5: Putting "Phings" together - how to automate your life](https://reader035.vdocuments.us/reader035/viewer/2022062404/554cb4d5b4c905335b8b4e5a/html5/thumbnails/5.jpg)
Why?
• Improves work quality• Eliminates repeatable
tasks• Minimises errors• Saves time and money• More code, less
configuration• Forces universal way of
automation• Tons of built-in tasks and
features
![Page 6: Putting "Phings" together - how to automate your life](https://reader035.vdocuments.us/reader035/viewer/2022062404/554cb4d5b4c905335b8b4e5a/html5/thumbnails/6.jpg)
Let’s install it
• Pear install$> pear channel-discover pear.phing.info $> pear install [--alldeps] phing/phing• Non pear install$> apt-get install pear$> pear channel-discover pear.phing.info $> pear install [--alldeps] phing/phing
![Page 7: Putting "Phings" together - how to automate your life](https://reader035.vdocuments.us/reader035/viewer/2022062404/554cb4d5b4c905335b8b4e5a/html5/thumbnails/7.jpg)
Using Phing
• phing -v• phing -f mybuildfile.xml• phing -f mybuildfile.xml mytarget• phing• phing mytarget• phing -l• phing -debug• phing -Dproperty.name=value
![Page 8: Putting "Phings" together - how to automate your life](https://reader035.vdocuments.us/reader035/viewer/2022062404/554cb4d5b4c905335b8b4e5a/html5/thumbnails/8.jpg)
Basics
• Build.xml• Project• Target• Task• Properties• Built-In Properties
![Page 9: Putting "Phings" together - how to automate your life](https://reader035.vdocuments.us/reader035/viewer/2022062404/554cb4d5b4c905335b8b4e5a/html5/thumbnails/9.jpg)
Build.xml
<project name="example" default="hello">
<target name="hello" > <echo>Hello world!</echo> </target> <target name= "bye"> <echo>Bye!</echo> </target></project>
![Page 10: Putting "Phings" together - how to automate your life](https://reader035.vdocuments.us/reader035/viewer/2022062404/554cb4d5b4c905335b8b4e5a/html5/thumbnails/10.jpg)
Project
<project name="example" default="world” description="Phing example">
<target name="world" description="Say world" depends="hello">
<echo>world!</echo> </target> <target name="hello" description="Say hello">
<echo>Hello</echo> </target></project>
![Page 11: Putting "Phings" together - how to automate your life](https://reader035.vdocuments.us/reader035/viewer/2022062404/554cb4d5b4c905335b8b4e5a/html5/thumbnails/11.jpg)
Target
<project name="example" default="world” description="Phing example">
<target name="world" description="Say world" depends="hello">
<echo>world!</echo> </target> <target name="hello" description="Say hello">
<echo>Hello</echo> </target></project>
![Page 12: Putting "Phings" together - how to automate your life](https://reader035.vdocuments.us/reader035/viewer/2022062404/554cb4d5b4c905335b8b4e5a/html5/thumbnails/12.jpg)
Task
<project name="example" default="world” description="Phing example">
<target name="world" description="Say world" depends="hello">
<echo>world!</echo> </target> <target name="hello" description="Say hello">
<echo>Hello</echo> </target></project>
![Page 13: Putting "Phings" together - how to automate your life](https://reader035.vdocuments.us/reader035/viewer/2022062404/554cb4d5b4c905335b8b4e5a/html5/thumbnails/13.jpg)
Properties
• Built-in properties• Custom properties• Declaration– Inline– External file– Input
![Page 14: Putting "Phings" together - how to automate your life](https://reader035.vdocuments.us/reader035/viewer/2022062404/554cb4d5b4c905335b8b4e5a/html5/thumbnails/14.jpg)
Properties
<project name="Example" default="default"> <property name="var1" value="value1"/> <property file="build.properties"/> <input propertyName="var3">Enter var3</input> <target name="default"> <echo>Variables: ${var1}, ${var2} and
${var3}</echo> </target></project>
![Page 15: Putting "Phings" together - how to automate your life](https://reader035.vdocuments.us/reader035/viewer/2022062404/554cb4d5b4c905335b8b4e5a/html5/thumbnails/15.jpg)
Build properties file
Drupal.site_name = “Test site”Drupal.profile = “standard”#commentProject.env = “dev”Project.git.url = “httpp://…”
![Page 16: Putting "Phings" together - how to automate your life](https://reader035.vdocuments.us/reader035/viewer/2022062404/554cb4d5b4c905335b8b4e5a/html5/thumbnails/16.jpg)
Tasks
• Core: – Copy, Delete, Echo, Exec, Move, Foreach, PhpEvalTask and more
• Optional: – FtpDeploy, GitPush, PDOSQL Exec, Scp, Zip, and more
![Page 17: Putting "Phings" together - how to automate your life](https://reader035.vdocuments.us/reader035/viewer/2022062404/554cb4d5b4c905335b8b4e5a/html5/thumbnails/17.jpg)
FileSet
<fileset dir="./application" includes="**" />
<fileset dir="./application" id="files">
<include name="**/*.php"/> <exclude name="**/*Test.php"/></fileset><fileset refid="files" />
![Page 18: Putting "Phings" together - how to automate your life](https://reader035.vdocuments.us/reader035/viewer/2022062404/554cb4d5b4c905335b8b4e5a/html5/thumbnails/18.jpg)
FileSet selectors
<fileset dir="${dist}"> <and> <filename name="**/*.log"/>
<date datetime="01/01/2013" when="before"/>
</and></fileset>
![Page 19: Putting "Phings" together - how to automate your life](https://reader035.vdocuments.us/reader035/viewer/2022062404/554cb4d5b4c905335b8b4e5a/html5/thumbnails/19.jpg)
Mappers
• Mappers are like filters for files and directories – Flatten – Glob– RegExp
<mapper type="mappername" from="frompattern" to="topattern" />
![Page 20: Putting "Phings" together - how to automate your life](https://reader035.vdocuments.us/reader035/viewer/2022062404/554cb4d5b4c905335b8b4e5a/html5/thumbnails/20.jpg)
FlattenMapper
<copy todir="/tmp"> <mapper type="flatten" /> <fileset refid="someid" />
</copy>
![Page 21: Putting "Phings" together - how to automate your life](https://reader035.vdocuments.us/reader035/viewer/2022062404/554cb4d5b4c905335b8b4e5a/html5/thumbnails/21.jpg)
GlobMapper
<copy todir="/tmp"> <mapper type="glob" from="*.php" to="*.php.bak"/>
<fileset refid="someid"/></copy>
![Page 22: Putting "Phings" together - how to automate your life](https://reader035.vdocuments.us/reader035/viewer/2022062404/554cb4d5b4c905335b8b4e5a/html5/thumbnails/22.jpg)
RegexpMapper
<mapper type="regexp" from="^(.*)\.conf\.xml" to="\1.php"/>
![Page 23: Putting "Phings" together - how to automate your life](https://reader035.vdocuments.us/reader035/viewer/2022062404/554cb4d5b4c905335b8b4e5a/html5/thumbnails/23.jpg)
Filters
• Filters Transform data/file contents within a task – Tidy – ExpandProperty– StripPhpComments– ReplaceRegexp– StripWhitespace
![Page 24: Putting "Phings" together - how to automate your life](https://reader035.vdocuments.us/reader035/viewer/2022062404/554cb4d5b4c905335b8b4e5a/html5/thumbnails/24.jpg)
TidyFilter
<filterchain><tidyfilter encoding="utf8"> <config name="indent" value="true" />
<config name="output-xhtml" value="true" />
</tidyfilter></filterchain>
![Page 25: Putting "Phings" together - how to automate your life](https://reader035.vdocuments.us/reader035/viewer/2022062404/554cb4d5b4c905335b8b4e5a/html5/thumbnails/25.jpg)
ExpandProperty<target name="config"> <property name="config.template" value="config.php-
dist" /> <property name="config.file" value="config.php" /> <property file="config.properties"
override="true" /> <copy file="${config.template}" tofile="$
{config.file}"> <filterchain> <expandproperties /> </filterchain> </copy></target>
![Page 26: Putting "Phings" together - how to automate your life](https://reader035.vdocuments.us/reader035/viewer/2022062404/554cb4d5b4c905335b8b4e5a/html5/thumbnails/26.jpg)
Extending Phing
• Tasks • Types • Selectors • Filters • Mappers • Loggers ...
![Page 27: Putting "Phings" together - how to automate your life](https://reader035.vdocuments.us/reader035/viewer/2022062404/554cb4d5b4c905335b8b4e5a/html5/thumbnails/27.jpg)
Sample task
SampleTask extends Task { private $var; public function setVar($v) { $this->var = $v; }
public function main() { print('value: ' . $this->var); }}
![Page 28: Putting "Phings" together - how to automate your life](https://reader035.vdocuments.us/reader035/viewer/2022062404/554cb4d5b4c905335b8b4e5a/html5/thumbnails/28.jpg)
Hey, is this a DrupalCamp or what?!
![Page 29: Putting "Phings" together - how to automate your life](https://reader035.vdocuments.us/reader035/viewer/2022062404/554cb4d5b4c905335b8b4e5a/html5/thumbnails/29.jpg)
Phing Drush Task
https://drupal.org/project/phingdrushtask
drush site-install --yes --locale=uk --site-name =${sitename} expert
<drush command="site-install" assume="yes""> <option name="locale">uk</option> <option name="site-name" value="${sitename}"/>
<param>expert</param></drush>
![Page 30: Putting "Phings" together - how to automate your life](https://reader035.vdocuments.us/reader035/viewer/2022062404/554cb4d5b4c905335b8b4e5a/html5/thumbnails/30.jpg)
How Phing is helping us
• Company is growing – from 30 to 75+ people in about a year
• Bigger projects – from 300 to 2000+ hours• Bigger teams – from 2 to 10+ team members • Many new employees• Many developers, many ways to manage a
project
![Page 31: Putting "Phings" together - how to automate your life](https://reader035.vdocuments.us/reader035/viewer/2022062404/554cb4d5b4c905335b8b4e5a/html5/thumbnails/31.jpg)
Thank you, Phing!
![Page 32: Putting "Phings" together - how to automate your life](https://reader035.vdocuments.us/reader035/viewer/2022062404/554cb4d5b4c905335b8b4e5a/html5/thumbnails/32.jpg)
What’s next
• http://phing.info• Adopt Phing for your
needs• Create new tasks• Contribute• Jenkins• https://github.com/relo
ad/phing-drupal-template
![Page 33: Putting "Phings" together - how to automate your life](https://reader035.vdocuments.us/reader035/viewer/2022062404/554cb4d5b4c905335b8b4e5a/html5/thumbnails/33.jpg)
Questions?