Skip to content

Building phpWebSite

Jeff Tickle edited this page Jun 4, 2013 · 5 revisions

Building phpWebSite

Why is there a build.xml file?

To compile the software, of course! Haha, but seriously, compilation is a small part of building a software release. Since phpWebSite is indeed written in php, you can simply clone the repository into a web root and have a website up and running in short order. However, if you are interested in developing phpWebSite, you should also write unit tests, document your code properly, and follow good programming practices. Build.xml is an Apache Ant build script (analogous to Makefile for you GNU AutoMake folks). Ours runs unit tests, generates documentation, and runs code metrics. We chose Ant since Jenkins Continuous Integration works well with it.

How can I run your build script?

You will need:

  1. Apache Ant, available from your favorite package manager
  2. Configure PEAR to auto_discover repositories:
pear config-set auto_discover 1
  1. PHP QA Tools, which can be installed from PEAR:
pear install pear.phpqatools.org/phpqatools
  1. ApiGen, which can also be installed from PEAR:
pear install pear.apigen.org/apigen

Then, in the root of your phpWebSite working directory:

ant

Your build script takes forever and I just want one metric. What Ant targets are available?

  • ant clean will clear out all of the build-related stuff and should shut Git up as well.
  • ant lint simply checks every .php file for syntax errors. If you intend to submit a pull request, you should have at least done this if nothing else.
  • ant phploc runs PHP Lines Of Code on phpWebSite
  • ant pdepend runs PHP Dependencies on phpWebSite
  • ant phpmd runs PHP Mess Detector on phpWebSite
  • ant phpcs runs PHP CheckStyle on phpWebSite, yet another good idea if you want to submit a pull request.
  • ant apigen runs APIGen, a documentation generator, on phpWebSite. For Pull Requests, your code should be well-documented and properly namespaced, and this step will help make such things apparent.
  • ant tarball builds a phpWebSite tarball
  • ant rpm builds a phpWebSite RPM - NOTE: RPM configuration is pretty custom tailored to our internal setup at this time and may not do what you want. You should probably take a look at the .spec file before building an RPM.
  • ant build is the default target when you run ant, and runs the above in more or less that order, and does not automatically build a tarball or RPM.

Continuous Integration is awesome. How can I learn more?

If you are interested in setting up Jenkins CI so that your own projects can be continuously integrated, I recommend reading this excellent guide all about it. As far as understanding Continuous Integration, best thing to do is just start from the guide and then tweak it as you go.