Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Phing

 Phing

Puneet Singhal

May 31, 2013
Tweet

More Decks by Puneet Singhal

Other Decks in Programming

Transcript

  1. Contents • Phing Build System • Why use it(advantages) •

    Features • What can it do • Example build files
  2. What is Phing • It is a PHP project build

    system or build tool based on Apache Ant. • Its use of simple XML build files and extensible PHP "task" classes make it an easy-to-use and highly flexible build framework.
  3. Advantages of using phing • Write once, run many •

    Is less vulnerable to human error • Human still write scripts to automate process • Can be scheduled, triggered, pushed and pulled • Behave always in the same way • So results can be predictable • Regular automated builds • Report on build status
  4. Features • Phing provides the following features: • Simple XML

    buildfiles • Rich set of provided tasks • Easily extendable via PHP classes • Platform-independent: works on UNIX, Windows, MacOSX • No required external dependencies • Built & optimized for ZendEngine2/PHP5
  5. What can this phing do? • Anything a shellscript can

    do(FTP, SCP, Chown, Touch, SSH etc.) for deployment • Integrate with version control(CVS, SVN, Git) • Code quality checks(phpcs, pdepend, phpmd, etc) • Unit tests(phpunit, simpletest) • Database deployment (dbdeploy) • Reporting(codecoverage, PHPDoc, DocBlox) • File transformations(e.g token replacement, XSLT transformation, Smarty template transformations) • File system operations, interactive build support • SQL execution • Tools for creating PEAR packages • Not enough? Write your own Tasks or Exec
  6. PHP_CodeSniffer • PHPCS:- PHP_CodeSniffer is a PHP5 script that tokenises

    PHP, JavaScript and CSS files to detect violations of a defined coding standard. It is an essential development tool that ensures your code remains clean and consistent. It can also help prevent some common semantic errors made by developers.
  7. PHPUnit as a Project Mess Detector • PHPMD:- PMD, also

    known as Project Mess Detector, is a popular tool in the Java world that scans Java source code and looks for potential problems. It is well integrated with other tools such as Eclipse or CruiseControl, making the collected information available at multiple points throughout the development process.
  8. How's it work? • Phing shell script, launches Phing PHP

    App + your XML build file. • Build file contains: • Properties • Targets • Tasks
  9. <?xml version="1.0" encoding="UTF-8"?> <project name="Copying PayPlans data to SVN" basedir="."

    default="copy_to_svn"> <property name="target" value="/vobs/payplans/scripts/../" override="true" /> <property name="source" value="${project.basedir}" override="true" /> <!-- decide joomla version --> <php function="file_exists" returnProperty="fileExist"> <param value="{source}/plugins/system/payplans.php"/> </php> <if> <istrue value="${fileExist}"/> <then> <!-- Joomla 1.5 --> <property name="JOOMLA_VERSION" value="J15" override="true" /> <echo>Joomla versions is : ${JOOMLA_VERSION}</echo> </then> <else> <!-- Joomla 1.6 --> </target>
  10. <!-- Copy Target --> <target name="copy_to_svn" description="copy target"> <phingcall target="copy_payplanspkg"

    /> </target> <target name="copy_plugin_J15"> <copy todir="${target}/source/admin/installer/apps/${target_plugin_folder}"> <fileset dir="${source}/plugins/${plugin_folder}"> <include name="${plugin_name}**" /> </fileset> </copy> </target>
  11. <!-- Copy Plugins --> <phingcall target=" copy_plugin_${JOOMLA_VERSION}"> <property name="target_plugin_folder" value="

    plg_payplans_system" /> <property name="plugin_folder" value="system" /> <property name="plugin_name" value=" payplans" /> </phingcall>
  12. <fileset dir="./test/test/" id="deleteScreenshots" > <include name=" sel/com/site/order/SCSOScreenshotTest/ screenshots/*.png" /> </fileset>

    <target name="screenshots"> <delete> <fileset refid="deleteScreenshots" /> </delete> </target>