Strategy for developing namespaced and non-namespaced versions of same PHP code

Posted by porneL on Stack Overflow See other posts from Stack Overflow or by porneL
Published on 2009-12-02T22:41:35Z Indexed on 2010/06/06 9:12 UTC
Read the original article Hit count: 261

I'm maintaining library written for PHP 5.2 and I'd like to create PHP 5.3-namespaced version of it. However, I'd also keep non-namespaced version up to date until PHP 5.3 becomes so old, that even Debian stable ships it ;)

I've got rather clean code, about 80 classes following Project_Directory_Filename naming scheme (I'd change them to \Project\Directory\Filename of course) and only few functions and constants (also prefixed with project name).

Question is: what's the best way to develop namespaced and non-namespaced versions in parallel?

  • Should I just create fork in repository and keep merging changes between branches? Are there cases where backslash-sprinkled code becomes hard to merge?

  • Should I write script that converts 5.2 version to 5.3 or vice-versa? Should I use PHP tokenizer? sed? C preprocessor?

  • Is there a better way to use namespaces where available and keep backwards compatibility with older PHP?

© Stack Overflow or respective owner

Related posts about php

Related posts about migration