PHP Summit in Düsseldorf

Sebastian Bergmann » 26 January 2010 » in Events » 0 Comments

PHP Summit

This blog posting is in German as the event it relates to is German-only. Sorry for the inconvenience. Our next training event in English will be in Montréal in March.

Der 1. PHP SUMMIT ist eine neue und einzigartige Veranstaltung mit dem Anspruch, alle wichtigen Themen von PHP in kompakter Form zu vermitteln. Hier können Sie drei Tage lang, jenseits der ausgetretenen Pfade von klassischen IT-Trainings im Unterrichtsstil mit Übungsaufgaben und Lernkontrolle, insgesamt 18 intensive und interaktive Power Workshops erleben.

Sämtliche Workshops beziehen sich auf die tägliche Projektarbeit und zeigen Ihnen den produktiven Live- Einsatz von Tools und Methoden. Hohe Interaktion mit den Teilnehmern, Live-Coding statt vorgefertigter foo/bar Beispiele, Informationen über neueste Trends in der PHP-Entwicklung — alles gewürzt mit einer guten Prise Humor — das sind die einzigartigen Merkmale des PHP SUMMIT. Darüber hinaus profitieren Sie vom geballten Wissen und der Praxiserfahrung der drei Experten von thePHP.cc: Sebastian Bergmann, Arne Blankerts und Stefan Priebsch.

Melden Sie sich noch heute an, um sich Ihren Platz zu reservieren!

Defined tags for this entry: ,

PHP Days Montréal

Sebastian Bergmann » 21 January 2010 » in Events » 0 Comments

Together with my friends and partners from thePHP.cc, Arne Blankerts and Stefan Priebsch, I will be giving an "Advanced PHP Development" training in Montréal in March.

  • How much effort is required to adapt your code to your customers' change requests?
  • Is it easy, or is it cumbersome and tedious?
  • And what about your code's complexity and readability?
  • Is everything crystal clear, or are there parts of the code base that nobody dares to touch anymore?
  • How often do you need to fix bugs after a release?
  • And, by the way: how easy is it to roll a release anyway?

If any of these questions made you blush with embarrassment, it is high time that you attend this training!

Learn how to turn bad code into good code and become better, more professional PHP developers. No question goes unanswered when we pull up an editor and explain best practices while we code a sample application live.

The PHP Days Montréal are a one-of-a-kind classroom training experience where all three thePHP.cc trainers will be present at all times. As the training is scheduled right before the ConFoo conference and the topics covered complement its presentations, the PHP Days Montréal are the perfect preparation for attendees to get the most out of the conference.

Register now to secure your seat as the number of attendees is limited to ensure a beneficial learning environment.

Defined tags for this entry: , ,

CRAP in PHPUnit 3.5

Sebastian Bergmann » 12 January 2010 » in New Features » 6 Comments

For the upcoming PHPUnit 3.5, I have factored out all code that is related to code coverage and put it into a separate component: PHP_CodeCoverage.

PHP_CodeCoverage is a component that provides collection, processing, and rendering functionality for PHP code coverage information. It makes PHPUnit's mature code coverage functionality available outside of PHPUnit.

Having all code that deals with code coverage in a separate component allows for easier development and better testing. The first result of these improved development conditions is a small new feature that I recently implemented, the support for the CRAP metric.

From crap4j.org:

The CRAP (Change Risk Analysis and Predictions) software metric [has] a mildly offensive metric name [and helps] to help protect you from truly offensive code.

The CRAP metric combines cyclomatic complexity and code coverage from automated tests (e.g. [PHPUnit] tests) to help you identify code that might be particularly difficult to understand, test, or maintain — the kind of code that makes developers say: “This is crap!” or, if they are stuck maintaining it, “Oh, crap!”.

The screenshot below shows how the CRAP metric is reported in the HTML code coverage report:

Code Coverage Report
Defined tags for this entry: , , ,

PHPUnit Development Moved to GitHub

Sebastian Bergmann » 26 December 2009 » in Announcements » 3 Comments

Over the Christmas holidays I took a break from translating and editing the book on quality assurance in PHP projects that I am working on to finally migrate the code repository of PHPUnit from a self-hosted Subversion repository to a Git repository that is hosted on GitHub.

How did I get here?

I was staying at Arjen's place in Brisbane in August 2008 and one day we talked about distributed version control. Although I knew the basic concepts behind it, I was not yet convinced enough to take the plunge and try it out. Our discussion changed that, but it was not until my second trip to Australia later that year that I took the initial code for PHP_ObjectFreezer (which I had on my laptop since I started to hack on it together with Stefan on the flight to Atlanta for php|works 2008) and put it into a bzr repository on Launchpad. I grew comfortable enough with bzr quickly, but never really warmed up to Launchpad.

Around that time, I was hearing more and more positive things about Git and GitHub from my peers. So I took the PHP_ObjectFreezer code base and migrated it to Git and hosted the repository and GitHub to experiment with both the tool and the platform. It was a step that I did not regret and all the projects that I started since then are hosted on GitHub: bytekit-cli, phpcpd, phpdcd, phploc, PHP_CodeCoverage, PHP_FileIterator, PHP_ObjectFreezer, Text_Template, PHP_TokenStream.

Why did I do this?

Let me start with a quote from GitHub.com:

  • Git is a fast, efficient, distributed version control system ideal for the collaborative development of software.
  • GitHub is the easiest (and prettiest) way to participate in that collaboration: fork projects, send pull requests, monitor development, all with ease.

Over the last year, I have come to appreciate Git and GitHub a lot and also wanted to use them for PHPUnit.

Sure, I could have used git-svn for bi-directional operation between the existing Subversion repository and Git, but this would have always felt like only going half the way.

The arguments in favour of distributed version control systems are discussed by others far better than I could discuss them here, so I will just quote Ian Clatworthy's paper on distributed version control systems, in which discusses not only the technical differences between traditional version control systems and distributed version control systems, but also the differences with regard to development workflows and developer interaction:

  • Developers can collaborate directly without needing central authority or incurring central administration overhead
  • Developers can still be productive when the umbilical cord to their central VCS repository is broken, e.g. when travelling.
  • Creating and destroying branches are simple operations. This is particularly useful when experimenting with new ideas, e.g. a spike when using eXtreme Programming.
  • Ad-hoc collaboration with peers [is facilitated by] intelligent merge tracking [because] merging early and merging often is both possible and surprisingly unpainful. It is difficult to explain just how much of an impact this can make on how co-developers can work together more easily, e.g. when Pair Programming.

What does this mean for you?

PHPUnit is now hosted on GitHub.

In a nutshell, this means that the development of PHPUnit is now more open than it was before. If you want to contribute, you just need to fork PHPUnit on GitHub and create a topic branch for your contribution. Then let me know about your topic branch and I may or may not merge it.

If you are currently using svn:externals to pull PHPUnit into your own Subversion repository, you need to think about an alternative as PHPUnit's Subversion repository is no longer updated and will eventually go away.

How did I do it?

As this might be of interest to someone who wants to migrate his/her repository from Subversion to Git, here is how I performed the migration.

I started by creating a local mirror of the Subversion repository:

# Fetch Subversion repository
svnadmin create phpunit.svn
 
cat <<'EOF' > phpunit.svn/hooks/pre-revprop-change
#!/bin/sh
USER="$3"
 
if [ "$USER" = "svnsync" ]; then exit 0; fi
 
echo "Only the svnsync user can change revprops" >&2
exit 1
EOF
 
chmod +x phpunit.svn/hooks/pre-revprop-change
 
svnsync init \
  --username svnsync \
  file://`pwd`/phpunit.svn \
  svn://svn.phpunit.de/phpunit
 
svnsync sync \
  --username svnsync \
  file://`pwd`/phpunit.svn

Then I used svn2git for the actual migration:

# Create directory for Git repository
mkdir phpunit.git && cd phpunit.git
 
# Use svn2git to import repository
svn2git \
  --trunk trunk \
  --branches branches/release \
  --tags tags \
  --authors /home/sb/authors.txt \
  file:///home/sb/phpunit.svn/phpunit

After that I had to delete quite a few superfluous branches and tags, but that quickly dealt with. The final step was to create common ancestors for the master, 3.5, and 3.4 branches so that merging becomes easy and painless.

# Create 3.5 and 3.4 branches (in local repository)
git checkout remotes/origin/3.5 -b 3.5
git checkout remotes/origin/3.4 -b 3.4

# Create common ancestors for the master, 3.5, and 3.4 branches
git checkout 3.5 && git merge --strategy=ours master
git checkout 3.4 && git merge --strategy=ours 3.5

git checkout master && git merge --strategy=ours 3.5
git checkout 3.5 && git merge --strategy=ours 3.4

After that I had to delete quite a few superfluous branches and tags, but that quickly dealt with.

At this point I would like to thank David Soria Parra who helped me figure out some details here and there.

Defined tags for this entry: , ,

PHPUnit 3.4.2

Sebastian Bergmann » 25 October 2009 » in Announcements » 3 Comments

I have released PHPUnit 3.4.2 today.

Besides the usual bug fixes, this release disables the backup and restore operations for static attributes (that was introduced in PHPUnit 3.4.0) by default.

The previous default setting caused too many problems with existing test suites (problems that would have been recognized earlier had users actually tested the PHPUnit 3.4 release candidates).

To enable the backup and restore operations for static attributes, simply pass the --static-backup command-line switch, use the @backupStaticAttributes annotation, or the XML configuration file.

Below is the full list of changes:

  • Fixed #889: --skeleton-class does not work with @depends annotation. [5270]
  • Fixed #902: PHPUnit_Util_File::getClassesInFile() does not handle nested namespaces correctly. [5272]
  • Fixed #905: Files with no methods or classes show incorrect code coverage with --coverage-clover. [5276] [5284]
  • Fixed #909: Stubbing a web service with getMockFromWsdl() throws a fatal error. [5281]
  • Fixed #918: Truncate operation throws an error. [5286]
  • The backup and restore operations for static attributes has been disabled by default. [5288]
Defined tags for this entry: ,

CodeWorks 2009

Sebastian Bergmann » 09 October 2009 » in Events » 0 Comments

I have to agree with Stefan: CodeWorks 2009 was a great experience. Thanks to everyone, especially Arbi, Keith and Matthew who herded the A-Team.

I would especially like to thank everybody who took the time and has provided me with their feedback on my "Quality Assurance in PHP Projects" workshop. Here are some excerpts:

"Was very happy with this workshop. I had been using custom build-once manual evaluation testing scripts in the past, but am convinced PHPUnit is the way to go.

Installed PHPUnit today and will start transitioning my current projects to start using these testing scripts now. [...]

These two tutorial workshops (this and the code review) were much more valuable to me than the several shorter ones from the main conference day."

Errol Sayre
"This was a good one. Good examples and even better talk. Introduction of new tools was perfect. Wanted to leave the conference to go home and start working them into our development cycle."
John Nunez
"In the week or so since I have caught this presentation, I have implemented every tool into the web2project development process, some for ongoing analysis, some for general metrics."
D. Keith Casey, Jr.

Arne, Stefan, and I also got some good feedback for our joint "PHP Code Review" workshop:

"I liked this one a lot. The best part was when they went over peoples code from the audience."
Lee Thornton
"I learned so much out of this session! Wish I could have had a recording of it because I know there was so much more I probably didn't pick up on as well."
Dorea Hardy
"The presentation was great, and I enjoyed the interaction with the group. Being able to review local developers code was also great."
Jake Smith

"I am kind of biased on this one as they reviewed my project, web2project.

This was excellent from top to bottom and a useful outside perspective on how to clean things up and make them better.

To date, I have completely reworked one of the modules based on the feedback and simplified the controllers, made the model better, and even improved the corresponding unit tests."

D. Keith Casey, Jr.
Defined tags for this entry: , , ,