wiki:Users/Documentation/Gotcha's

Phing 2.4 - basedir attribute

Phing 2.4 introduces some changes in the handling of the 'basedir' attribute in the 'project' tag in each build file.

In Ant (see  http://ant.apache.org/manual/using.html) and Phing (<= 2.3.3), not specifying the basedir attribute means the same as basedir=".", namely the parent directory of the build file that is called. Adding basedir="." seems to be common practice in a lot of build files (esp. Ant), even though that only adds verbosity (and maybe clarity).

Since "." reflects the current working directory in other tools, this behavior was (in my mind anyway) ambigious. Now, there are three modes of using the basedir attribute:

  • not specifying it; same behavior as before, basedir = parent dir of the build file
  • specifiying "."; basedir = current working directory, i.e. the dir you started phing from
  • specifying anything else; basedir = relative or absolute path lookup

Phing and XAMPP

The following problem might occur when using XAMPP 1.7.2 (other versions haven't been tested or reported):

I have a build.xml file (attached) which works fine if it lies in C:\xampp and doesn't work if it lies in C:\xampp\htdocs

The error which occurs is "Can't locate default task list"

A user suggested the following fix:

I solved this problem by adding the pear/data directory into php include_path

<< include_path = ".;D:\xampp\php\PEAR"
>> include_path = ".;D:\xampp\php\PEAR;D:\xampp\php\PEAR\data"

Full details available here:  ticket #376.

Windows and installation gotchas

<< previous comments about SVN and Windows are obsolete because of fixes in the PEAR  VersionControl_SVN package >>

Oh, and just a note on installing phing. Here's what I do to get everything needed. If there is a better way please let me know, otheriwise this might help some people:

$ pear channel-discover pear.phing.info
$ pear install --alldeps phing/phing
$ pear install --alldeps channel://pear.php.net/VersionControl_SVN-0.3.0alpha1
$ pear install --alldeps channel://pear.php.net/PhpDocumentor-1.3.0RC6
$ pear install --alldeps http://creole.phpdb.org/pear/creole-current.tgz
$ pear install --alldeps http://creole.phpdb.org/pear/jargon-current.tgz

It's the same on windows providing PEAR is set up properly on your install.

Andrew Eddie

"Cannot redeclare class" solution

In a nutshell, the problem was "Cannot redeclare class" errors being caused by files including things from both the testing directory (build target) and the current working directory (sandbox).

The solution was to add the following line to my build.xml file:

<includepath classpath="${build.target.dir}:${php.classpath}" />

This simply made my target directory take precidence over my current working directory. Ideally the cwd would be completely excluded but I haven't figured that one out yet, so I'll leave that as an exercise left up to the reader ;)

Harlan Iverson