Phing - A PHP Build Tool (An Introduction)
Upcoming SlideShare
Loading in...5
×
 

Phing - A PHP Build Tool (An Introduction)

on

  • 9,622 views

PHing Is Not GNU make; it's a PHP project build system or build tool based on Apache Ant. ...

PHing Is Not GNU make; it's a PHP project build system or build tool based on Apache Ant.

These are slides from my talk during the Unconference at the Dutch PHP 2011 Conference (Amsterdam). During this talk I gave an overview of the features and how to use, adapt and extend Phing.

Statistics

Views

Total Views
9,622
Views on SlideShare
8,686
Embed Views
936

Actions

Likes
8
Downloads
138
Comments
0

6 Embeds 936

http://www.touchdownconsulting.nl 927
http://www.linkedin.com 3
http://twitter.com 2
https://www.linkedin.com 2
http://us-w1.rockmelt.com 1
http://www.google.it 1

Accessibility

Categories

Upload Details

Uploaded via as OpenOffice

Usage Rights

CC Attribution-NonCommercial LicenseCC Attribution-NonCommercial License

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    Phing - A PHP Build Tool (An Introduction) Phing - A PHP Build Tool (An Introduction) Presentation Transcript

    • Phing – A PHP Build Tool An Introduction Michiel Rook DPC 2011 - Uncon
    • About me Michiel Rook
      • Freelance PHP/Java consultant
      • Phing project lead
      • http://nl.linkedin.com/in/michieltcs
      • @michieltcs
    • About Phing
      • “PHing Is Not GNU make; it's a PHP project build system or build tool based on Apache Ant.”
      • Originally developed by Binarycloud
      • Ported to PHP5 by Hans Lellelid
      • I joined in 2005
    • Features
      • Scripting using XML build files
      • Mostly cross platform
      • Interface to various popular (PHP) tools
    • Features
    • Installation
      • PEAR installation $ pear channel-discover pear.phing.info $ pear install [--alldeps] phing/phing
      • Optionally install the documentation $ pear install phing/phingdocs
    • Why A Build Tool?
    • Why A Build Tool
      • Repetitive tasks
        • Version control
        • (Unit) Testing
        • Configuring
        • Packaging
        • Uploading
        • DB changes
        • ...
    • Why A Build Tool
      • For developers and deployments
      • Automate!
        • Easier handover to new team members
        • Improves quality
        • Reduces errors
        • Saves time
    • Why Phing
      • Rich set of tasks
      • Integration with PHP specific tools
      • Allows you to stay in the PHP infrastructure
      • Easy to extend
      • Embed PHP code directly in the build file
    • Why Phing
      • Rich set of tasks
      • Integration with PHP specific tools
      • Allows you to stay in the PHP infrastructure
      • Easy to extend
      • Embed PHP code directly in the build file
      • … in the end, the choice is yours
    • The Basics
      • Phing uses XML build files
      • Standard elements
        • Task : code that performs a specific function (svn checkout, mkdir, etc.)
        • Target : groups of tasks, can optionally depend on other targets
        • Project : root node, contains multiple targets
    • Example Build File < project name = &quot;Example&quot; default = &quot;world&quot; > < target name = &quot;hello&quot; > < echo > Hello </ echo > </ target > < target name = &quot;world&quot; depends = &quot;hello&quot; > < echo > World! </ echo > </ target > </ project >
    • Properties < project name = &quot;Example&quot; default = &quot;default&quot; > < property file = &quot;build.properties&quot; / > < target name = &quot;default&quot; > < echo > ${version} </ echo > </ target > </ project > ## build.properties version=1.0
    • FileSet
      • Constructs a group of files to process
      • Supported by most tasks
      < fileset dir = &quot;./application&quot; > <include name = &quot;**/*.php&quot; / > <exclude name = &quot;**/*.php&quot; / > </ fileset > < fileset dir = &quot;./application&quot; includes = &quot;**&quot; / > < fileset dir = &quot;./application&quot; id = &quot;files&quot; > <include name = &quot;**/*.php&quot; / > <exclude name = &quot;**/*Test.php&quot; / > </ fileset > < fileset refid = &quot;files&quot; / >
    • FileSet
      • Selectors allow fine-grained matching on certain attributes
      < fileset dir = &quot;${dist}&quot; > <and> <filename name = &quot;**&quot; /> <date datetime = &quot;01/01/2011&quot; when = &quot;before&quot; /> </and> </ fileset >
    • Mappers & Filters
      • Transform files during copy/move/...
      • Mappers
        • Change filename
      • Filters
        • Strip comments
        • Replace values
        • Perform XSLT transformation
        • Translation (i18n)
    • Mappers & Filters < copy todir = &quot;${build}&quot; > <fileset refid = &quot;files&quot; / > <mapper type = &quot;glob&quot; from = &quot;*.txt&quot; type = &quot;*.new.txt&quot; / > <filterchain> <replaceregexp> <regexp pattern = &quot;rn&quot; replace = &quot;n&quot; /> </replaceregexp> </filterchain> </ copy >
    • Testing
      • Built-in support for PHPUnit / SimpleTest / Xdebug
      • Various output formats
    • Testing < target name = &quot;test&quot; > < coverage-setup database = &quot;reports/coverage.db&quot; > < fileset dir = &quot;src&quot; > < include name = &quot;**/*.php&quot; /> < exclude name = &quot;**/*Test.php&quot; /> </ fileset > </ coverage-setup > < phpunit codecoverage = &quot;true&quot; > < formatter type = &quot;xml&quot; todir = &quot;reports&quot; /> < formatter type = &quot;clover&quot; todir = &quot;.&quot; /> < batchtest > < fileset dir = &quot;src&quot; > < include name = &quot;**/*Test.php&quot; /> </ fileset > </ batchtest > </ phpunit >
    • Testing < phpunitreport infile = &quot;reports/testsuites.xml&quot; format = &quot;frames&quot; todir = &quot;reports/tests&quot; styledir = &quot;../../etc&quot; /> < coverage-report outfile = &quot;reports/coverage.xml&quot; > < report todir = &quot;reports/coverage&quot; styledir = &quot;../../etc&quot; title = &quot;Demo&quot; /> </ coverage-report > </ target >
    • Extending Phing
      • Numerous possibilities
        • Tasks
        • Types
        • Selectors
        • Filters
        • Mappers
        • Loggers
        • ...
    • Sample Task class SampleTask extends Task { private $var ; public function setVar($v) { $this-> var = $v; } public function main() { $this->log( &quot;value: &quot; . $this-> var ); } }
    • Sample Task < project name = &quot;Example&quot; default = &quot;default&quot; > < taskdef name = &quot;sample&quot; classname = &quot;phing.tasks.my.SampleTask&quot; /> < target name = &quot;default&quot; > < sample var = &quot;Hello World&quot; /> </ target > </ project >
    • Ad Hoc Extension < target name = &quot;main&quot; > <adhoc-task name = &quot;foo&quot; > <![CDATA[ class FooTest extends Task { private $bar; function setBar($bar) { $this->bar = $bar; } function main() { $this->log(&quot;In FooTest: &quot; . $this->bar); } } ]]> </ adhoc-task > <foo bar = &quot;TEST&quot; / > </ target >
    • More Uses For Phing
      • Installation
      • Bootstrap dev. environments
      • DB migrations
      • Analyze code
      • Run (unit) tests
      • Upgrade server
    • What's Next For Phing
      • Improvements
        • More tasks (DocBlox), bug fixes
        • Test coverage
        • Cross-platform compatibility
        • Pain-free installation of dependencies
        • IDE support
      • We would love more contributions!
    • Questions? http://www.phing.info http://joind.in/3475 #phing (freenode) @phingofficial