Php is now used by many CMS, many of which use a modular system with a wide
range of add-ons developed by third parties. This can cause various
conflicts, such as when two or more external components using the same
library (i.g. with a different version) in this case the classes /
namespace will be in collision. This can become unmanageable by the
webmaster because they are not always able to change third parties code and
there aren't other "clean" methods to solve this kind of problem ( complex
and dirty eval methods excluded ).

here you are a thread related to this issue:
http://stackoverflow.com/questions/17628475/php-include-different-version-of-same-library

*One possible solution* would be to extend the scoping for the inclusions
of files using something like:* local_include_**

in this way you can also create a sort of "nesting" system for classes
making possible a syntax like this:

class foo {
     public static function bar () {
          local_include "test.php" / / file which includes "test" class;
          return new test ();
     }
}

echo get_class (foo :: bar ()) / / output: "test"

new test () / / raise an error instead


*Also this could work:*

namespace {oldversion
    local_include / lib/api-1.0/library.php;
}
namespace {newversion
    local_include / lib/api-2.0/library.php;
}

$ oldlibary = new oldversion \ Library ();
$ newlibrary = new newversion \ Library ();

It shouldn't have backward compatibility issues since it's a new
implementation and you shouldn't change anything else.
What do you think about that?

Reply via email to