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

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×

Introducing the official SlideShare app

Stunning, full-screen experience for iPhone and Android

Text the download link to your phone

Standard text messaging rates apply

Phing - A PHP Build Tool (An Introduction)

9,685
views

Published on

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.

Published in: Technology

0 Comments
7 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
9,685
On Slideshare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
149
Comments
0
Likes
7
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. Phing – A PHP Build Tool An Introduction Michiel Rook DPC 2011 - Uncon
  • 2. About me Michiel Rook
    • Freelance PHP/Java consultant
    • 3. Phing project lead
    • 4. http://nl.linkedin.com/in/michieltcs
    • 5. @michieltcs
  • 6. About Phing
    • “PHing Is Not GNU make; it's a PHP project build system or build tool based on Apache Ant.”
    • 7. Originally developed by Binarycloud
    • 8. Ported to PHP5 by Hans Lellelid
    • 9. I joined in 2005
  • 10. Features
    • Scripting using XML build files
    • 11. Mostly cross platform
    • 12. Interface to various popular (PHP) tools
  • 13. Features
  • 14. Installation
    • PEAR installation $ pear channel-discover pear.phing.info $ pear install [--alldeps] phing/phing
    • 15. Optionally install the documentation $ pear install phing/phingdocs
  • 16. Why A Build Tool?
  • 17. Why A Build Tool
  • 24. Why A Build Tool
    • For developers and deployments
    • 25. Automate!
      • Easier handover to new team members
      • 26. Improves quality
      • 27. Reduces errors
      • 28. Saves time
  • 29. Why Phing
    • Rich set of tasks
    • 30. Integration with PHP specific tools
    • 31. Allows you to stay in the PHP infrastructure
    • 32. Easy to extend
    • 33. Embed PHP code directly in the build file
  • 34. Why Phing
    • Rich set of tasks
    • 35. Integration with PHP specific tools
    • 36. Allows you to stay in the PHP infrastructure
    • 37. Easy to extend
    • 38. Embed PHP code directly in the build file
    • 39. … in the end, the choice is yours
  • 40. The Basics
    • Phing uses XML build files
    • 41. Standard elements
      • Task : code that performs a specific function (svn checkout, mkdir, etc.)
      • 42. Target : groups of tasks, can optionally depend on other targets
      • 43. Project : root node, contains multiple targets
  • 44. 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 >
  • 45. 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
  • 46. FileSet
    • Constructs a group of files to process
    • 47. 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; / >
  • 48. 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 >
  • 49. Mappers & Filters
    • Transform files during copy/move/...
    • 50. Mappers
      • Change filename
    • Filters
      • Strip comments
      • 51. Replace values
      • 52. Perform XSLT transformation
      • 53. Translation (i18n)
  • 54. 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 >
  • 55. Testing
    • Built-in support for PHPUnit / SimpleTest / Xdebug
    • 56. Various output formats
  • 57. 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 >
  • 58. 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 >
  • 59. Extending Phing
  • 66. 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 ); } }
  • 67. 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 >
  • 68. 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 >
  • 69. More Uses For Phing
  • 75. What's Next For Phing
    • Improvements
      • More tasks (DocBlox), bug fixes
      • 76. Test coverage
      • 77. Cross-platform compatibility
      • 78. Pain-free installation of dependencies
      • 79. IDE support
    • We would love more contributions!
  • 80. Questions? http://www.phing.info http://joind.in/3475 #phing (freenode) @phingofficial