Skip to content
Composer plugin that wraps all composer vendor packages inside your own namespace. Intended for WordPress plugins.
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
src Fix: Type check correctly Mar 26, 2017
tests 🚲Bikeshedding Sep 25, 2018
.gitattributes 🚲Bikeshedding Sep 25, 2018
.github_changelog_generator Version bump 0.3.1 Sep 25, 2018
.gitignore 🚲Bikeshedding Sep 25, 2018
.travis.yml 🚲Bikeshedding Sep 25, 2018
CHANGELOG.md Version bump 0.3.1 Sep 25, 2018
CODE_OF_CONDUCT.md Rename: .github/CONDUCT.md --> CODE_OF_CONDUCT.md Aug 21, 2017
LICENSE First commit Mar 19, 2017
README.md Version bump 0.3.1 Sep 25, 2018
codeception.yml 🚲Bikeshedding Sep 25, 2018
composer.json
phpcs.xml 🚲Bikeshedding Sep 25, 2018

README.md

Imposter Plugin

Latest Stable Version PHP from Packagist Total Downloads Build 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.

Why?

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.

See:

Install

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": [
            "dummy/dummy-excluded"
        ]
    }
}

See: Imposter readme for details.

Usage

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
$ composer dump-autoload

Note: You need to run $ composer dump-autoload after every $ composer imposter:run.

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

Learn more on imposter's readme.

Frequently Asked Questions

What can I find more information?

Learn more on imposter's readme for more details.

How about not hooking into composer commands?

Use imposter directly.

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

Here you go:

Add your own here

Will you add support for older PHP versions?

Never! This package will only works on actively supported PHP versions. Don't use it on end of life or security fixes only PHP versions.

It looks awesome. Where can I find some more goodies like this?

This package isn't on wp.org. Where can I give a ⭐️⭐️⭐️⭐️⭐️ review?

Thanks!

Consider writing a blog post, submitting pull requests, donating or hiring me instead.

Alternatives

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
  • PHP Scoper

    • Prefixes all PHP namespaces in a file/directory to isolate the code bundled in PHARs

Support

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

Running the Tests

Run the tests:

$ composer test
$ composer check-style

Feedback

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.

Security

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

Credits

imposter-plugin is a Typist Tech project and maintained by Tang Rufus, freelance developer for hire.

Full list of contributors can be found here.

License

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

You can’t perform that action at this time.