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

前端 未结 9 2087
时光取名叫无心
时光取名叫无心 2020-12-23 13:43

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.

9条回答
  •  没有蜡笔的小新
    2020-12-23 14:25

    What I did, with a large codebase that used the underscore naming convention (among others), and require_once a whole lot in lieu of an autoloader, was to define an autoloader, and add class_alias lines in the files defining aliases to a classes old name after changing their names to be nice with namespaces.

    I then started removing require_once statements where execution was not dependent on inclusion order, since the autoloader would pick stuff up, and namespace stuff as I went along fixing bugs and so on.

    It's worked quite well so far.

提交回复
热议问题