Composer plugin that wraps all composer vendor packages inside your own namespace. Intended for WordPress plugins

0.3.0 2018-01-16 09:45 UTC


Latest Stable Version Total Downloads Build Status Scrutinizer Code Quality PHP Versions Tested StyleCI Dependency Status License Donate via PayPal Hire Typist Tech

Wrapping all composer vendor packages inside your own namespace. Intended for WordPress plugins. Imposter Plugin is a composer plugin wrapper for Imposter.


Because of the lack of dependency management in WordPress, if two plugins bundled conflicting versions of the same package, hard-to-reproduce bugs arise. Monkey patching composer vendor packages, wrapping them inside your own namespace is a less-than-ideal solution to avoid such conflicts.



Installation should be done via composer, details of how to install composer can be found at https://getcomposer.org/.

$ composer require typisttech/imposter-plugin

Then, config Imposter in your composer.json

"extra": {
    "imposter": {
        "namespace": "My\\App\\Vendor",
        "excludes": [

See: Imposter readme for details.


Sit Back and Relax

Once installed, Imposter Plugin hooks into composer install, composer update and composer dump-autoload, automatically run Imposter for you. Besides, Imposter Plugin autoloads all modified files as classmap.

composer imposter:run

If you want to run Imposter manually:

$ composer imposter:run

Note: You need to run $ composer dump-autoload after this command.

This command:

  1. Look for /path/to/project/root/composer.json
  2. Find out vendor-dir
  3. Find out all required packages, including those required by dependencies
  4. Find out all autoload paths for all required packages
  5. Prefix all namespaces with the imposter-plugin namespace defined in your composer.json



namespace Dummy\File;

use AnotherDummy\{
    SubAnotherDummy, SubOtherDummy
use Dummy\SubOtherDummy;
use OtherDummy\SubOtherDummy;
use RuntimeException;
use \UnexpectedValueException;

class DummyClass



namespace My\App\Vendor\Dummy\File;

use My\App\Vendor\AnotherDummy\{
    SubAnotherDummy, SubOtherDummy
use My\App\Vendor\Dummy\SubOtherDummy;
use My\App\Vendor\OtherDummy\SubOtherDummy;
use RuntimeException;
use \UnexpectedValueException;

class DummyClass

Frequently Asked Questions

What can I find out more information?

Imposter plugin is a composer plugin wrapper for Imposter. See: Imposter for more details.

Does Imposter Plugin support PSR4, PSR0, Classmap and Files?

Yes for all. PSR-4 and PSR-0 autoloading, classmap generation and files includes are supported.

Does Imposter Plugin support exclude-from-classmap?

Not for now. Pull requests are welcome.

How about require-dev packages?

Imposter Plugin do nothing on require-dev packages because imposter-plugin is intended for avoiding production environment., not for development environment.

How about PHP built-in classes?

Imposter skips classes that on global namespace, for example: \ArrayObject, \RuntimeException

How about packages that don't use namespaces?

Not for now. Tell me your idea by opening an issue

How about packages that use fully qualified name?

Not for now. We need a better regex in the Transformer class. Tell me your idea by opening an issue

Do you have real life examples that use this composer plugin?

Here you go:

Add your own here



Love Imposter Plugin? Help me maintain it, a donation here can help with it.

Why don't you hire me?

Ready to take freelance WordPress jobs. Contact me via the contact form here or, via email info@typist.tech

Want to help in other way? Want to be a sponsor?

Contact: Tang Rufus


Here is a list of alternatives that I found. But none satisfied my requirements.

If you know other similar projects, feel free to edit this section!

  • Mozart by Coen Jacobs
    • Works with PSR0 and PSR4
    • Dependency packages store in a different directory


To setup a developer workable version you should run these commands:

$ composer create-project --keep-vcs --no-install typisttech/imposter-plugin:dev-master
$ cd imposter-plugin
$ composer install

Running the Tests

Imposter Plugin run tests on Codeception.

Run the tests:

$ composer test

// Or, run with coverage support
$ composer test-with-coverage

We also test all PHP files against PSR-2: Coding Style Guide.

Check the code style with $ composer check-style and fix it with $ composer fix-style.


Please provide feedback! We want to make this library useful in as many projects as possible. Please submit an issue and point out what you do and don't like, or fork the project and make suggestions. No issue is too small.

Change log

Please see CHANGELOG for more information on what has changed recently.


If you discover any security related issues, please email imposter-plugin@typist.tech instead of using the issue tracker.


Please see CONTRIBUTING and CODE_OF_CONDUCT for details.


Imposter Plugin is a Typist Tech project and maintained by Tang Rufus, freelance developer for hire.

Full list of contributors can be found here.


The MIT License (MIT). Please see License File for more information.