PHP-Scoper prefixes all PHP namespaces in a file/directory.

1.0-beta 2017-04-02 17:45 UTC


Build Status Build status Scrutinizer Code Quality Latest Stable Version Total Downloads Dependency Status

Latest release: none

PHP >= 5.5

PHP-Scoper is a tool for adding a prefix to all PHP namespaces in a given file or directory.


PHP-Scoper's goal is to make sure that all code in a directory lies in a distinct PHP namespace. This is necessary when building PHARs that

  • bundle their own vendor dependencies
  • load code of arbitrary PHP projects

These PHARs run the risk of raising conflicts between their bundled vendors and the vendors of the loaded project, if the vendors are required in incompatible versions.


Use PHP-Scoper like this:

$ php-scoper add-prefix MyPhar\\ .

The first argument is the prefix to add to all namespace declarations and class usages. The second argument is one or more files/directories which should be processed.



Contributions to are very welcome!


If you are having problems, send a mail to or shout out to @webmozart on Twitter.


All contents of this package are licensed under the MIT license.