Skip to content

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

License

Notifications You must be signed in to change notification settings

ajgagnon/imposter-plugin

 
 

Repository files navigation

Imposter Plugin

Packagist Packagist PHP from Packagist CircleCI GitHub GitHub Sponsor Sponsor via PayPal Hire Typist Tech Twitter Follow @TangRufus

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/.

First, add Imposter configuration in your composer.json

"extra": {
    "imposter": {
        "namespace": "My\\App\\Vendor",
        "excludes": [
            "dummy/dummy-excluded"
        ]
    }
}

Then, install via composer cli

$ composer require typisttech/imposter-plugin

See: Imposter readme for details.

Usage

Sit Back and Relax

Once installed, this 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.

When those events triggered, this plugin:

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

Learn more on imposter's readme.

Known Issues

Help wanted. Pull requests are welcomed.

  1. Imposter run twice when composer install and composer update
  2. Traits are not transformed
  3. Virtual packages are not supported

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 plugin will only work 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?

Where can I give ⭐⭐⭐⭐⭐ reviews?

Thanks! Glad you like it. It's important to let my know somebody is using this project. Since this is not hosted on wordpress.org, please consider:

Sponsoring ❤️

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

GitHub Sponsors Matching Fund

Do you know GitHub is going to match your sponsorship?

Sponsor now via GitHub to double your greatness.

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 style:check

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

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.

About

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

Resources

License

Code of conduct

Stars

Watchers

Forks

Packages

No packages published

Languages

  • PHP 100.0%