src
3 years ago
LICENSE
3 years ago
README.md
3 years ago
composer.json
3 years ago
composer.lock
3 years ago
README.md
201 lines
| 1 | <div align="center"> |
| 2 | |
| 3 | # Imposter Plugin |
| 4 | |
| 5 | </div> |
| 6 | |
| 7 | <div align="center"> |
| 8 | |
| 9 | |
| 10 | [](https://packagist.org/packages/typisttech/imposter-plugin](https://packagist.org/packages/typisttech/imposter-plugin](https://packagist.org/packages/typisttech/imposter-plugin) |
| 11 | [](https://packagist.org/packages/typisttech/imposter-plugin](https://packagist.org/packages/typisttech/imposter-plugin](https://packagist.org/packages/typisttech/imposter-plugin) |
| 12 | [](https://packagist.org/packages/typisttech/imposter-plugin](https://packagist.org/packages/typisttech/imposter-plugin](https://packagist.org/packages/typisttech/imposter-plugin) |
| 13 | [](https://circleci.com/gh/TypistTech/imposter-plugin](https://circleci.com/gh/TypistTech/imposter-plugin](https://circleci.com/gh/TypistTech/imposter-plugin) |
| 14 | [](https://github.com/TypistTech/imposter-plugin/blob/master/LICENSE](https://github.com/TypistTech/imposter-plugin/blob/master/LICENSE](https://github.com/TypistTech/imposter-plugin/blob/master/LICENSE) |
| 15 | [](https://twitter.com/tangrufus](https://twitter.com/tangrufus](https://twitter.com/tangrufus) |
| 16 | [](https://www.typist.tech/contact/](https://www.typist.tech/contact/](https://www.typist.tech/contact/) |
| 17 | |
| 18 | </div> |
| 19 | |
| 20 | <p align="center"> |
| 21 | <strong>Composer plugin that wraps all composer vendor packages inside your own namespace. Intended for WordPress plugins.</strong> |
| 22 | <br /> |
| 23 | <br /> |
| 24 | Built with ♥ by <a href="https://www.typist.tech/">Typist Tech</a> |
| 25 | </p> |
| 26 | |
| 27 | --- |
| 28 | |
| 29 | **Imposter Plugin** is an open source project and completely free to use. |
| 30 | |
| 31 | However, the amount of effort needed to maintain and develop new features is not sustainable without proper financial backing. If you have the capability, please consider donating using the links below: |
| 32 | |
| 33 | <div align="center"> |
| 34 | |
| 35 | [](https://github.com/sponsors/TangRufus](https://github.com/sponsors/TangRufus](https://github.com/sponsors/TangRufus) |
| 36 | [](https://typist.tech/go/paypal-donate/](https://typist.tech/go/paypal-donate/](https://typist.tech/go/paypal-donate/) |
| 37 | [](https://typist.tech/donate/imposter-plugin/](https://typist.tech/donate/imposter-plugin/](https://typist.tech/donate/imposter-plugin/) |
| 38 | |
| 39 | </div> |
| 40 | |
| 41 | --- |
| 42 | |
| 43 | Wrapping all composer vendor packages inside your own namespace. Intended for WordPress plugins. Imposter Plugin is a composer plugin wrapper for [](https://github.com/TypistTech/imposter/Imposter](https://github.com/TypistTech/imposter/](https://github.com/TypistTech/imposter/). |
| 44 | |
| 45 | ## Why? |
| 46 | |
| 47 | Because of the lack of dependency management in WordPress, if two plugins bundled conflicting versions of the same package, hard-to-reproduce bugs arise. |
| 48 | Monkey patching composer vendor packages, wrapping them inside your own namespace is a less-than-ideal solution to avoid such conflicts. |
| 49 | |
| 50 | See: |
| 51 | - [](https://wptavern.com/a-narrative-of-using-composer-in-a-wordpress-pluginA Narrative of Using Composer in a WordPress Plugin](https://wptavern.com/a-narrative-of-using-composer-in-a-wordpress-plugin](https://wptavern.com/a-narrative-of-using-composer-in-a-wordpress-plugin) |
| 52 | - [](https://wppusher.com/blog/a-warning-about-using-composer-with-wordpress/A Warning About Using Composer With WordPress](https://wppusher.com/blog/a-warning-about-using-composer-with-wordpress/](https://wppusher.com/blog/a-warning-about-using-composer-with-wordpress/) |
| 53 | |
| 54 | ## Install |
| 55 | |
| 56 | Installation should be done via composer, details of how to install composer can be found at [](https://getcomposer.org/https://getcomposer.org/](https://getcomposer.org/](https://getcomposer.org/). |
| 57 | |
| 58 | First, add Imposter configuration in your `composer.json` |
| 59 | |
| 60 | ```json |
| 61 | "extra": { |
| 62 | "imposter": { |
| 63 | "namespace": "My\\App\\Vendor", |
| 64 | "excludes": [ |
| 65 | "dummy/dummy-excluded" |
| 66 | ] |
| 67 | } |
| 68 | } |
| 69 | ``` |
| 70 | |
| 71 | Then, install via composer cli |
| 72 | |
| 73 | ```bash |
| 74 | composer require typisttech/imposter-plugin |
| 75 | ``` |
| 76 | |
| 77 | See: [](https://github.com/Typisttech/imposter#configImposter readme](https://github.com/Typisttech/imposter#config](https://github.com/Typisttech/imposter#config) for details. |
| 78 | |
| 79 | --- |
| 80 | |
| 81 | <p align="center"> |
| 82 | <strong>Typist Tech is ready to build your next awesome WordPress site. <a href="https://typist.tech/contact/">Hire us!</a></strong> |
| 83 | </p> |
| 84 | |
| 85 | --- |
| 86 | |
| 87 | ## Usage |
| 88 | |
| 89 | ### Sit Back and Relax |
| 90 | |
| 91 | Once installed, this plugin hooks into `composer install`, `composer update` and `composer dump-autoload`, automatically run [](https://github.com/TypistTech/imposter/imposter](https://github.com/TypistTech/imposter/](https://github.com/TypistTech/imposter/) for you. |
| 92 | Besides, imposter plugin autoloads all modified files as [](https://getcomposer.org/doc/04-schema.md#classmapclassmap](https://getcomposer.org/doc/04-schema.md#classmap](https://getcomposer.org/doc/04-schema.md#classmap). |
| 93 | |
| 94 | When those events triggered, this plugin: |
| 95 | 1. looks for `/path/to/project/root/composer.json` |
| 96 | 2. finds out [](https://getcomposer.org/doc/06-config.md#vendor-dirvendor-dir](https://getcomposer.org/doc/06-config.md#vendor-dir](https://getcomposer.org/doc/06-config.md#vendor-dir) |
| 97 | 3. finds out all [](https://getcomposer.org/doc/04-schema.md#requirerequired packages](https://getcomposer.org/doc/04-schema.md#require](https://getcomposer.org/doc/04-schema.md#require), including those required by dependencies |
| 98 | 4. finds out all [](https://getcomposer.org/doc/04-schema.md#autoloadautoload paths](https://getcomposer.org/doc/04-schema.md#autoload](https://getcomposer.org/doc/04-schema.md#autoload) for all required packages |
| 99 | 5. prefixes all namespaces with the imposter-plugin namespace defined in your `composer.json` |
| 100 | |
| 101 | Learn more on [](https://github.com/TypistTech/imposter#usageimposter's readme](https://github.com/TypistTech/imposter#usage](https://github.com/TypistTech/imposter#usage). |
| 102 | |
| 103 | ## Known Issues |
| 104 | |
| 105 | Help wanted. Pull requests are welcomed. |
| 106 | |
| 107 | 1. Imposter run twice when `composer install` and `composer update` |
| 108 | 1. Traits are not transformed |
| 109 | 1. Virtual packages are not supported |
| 110 | |
| 111 | ## Frequently Asked Questions |
| 112 | |
| 113 | ### What can I find more information? |
| 114 | |
| 115 | Learn more on [](https://github.com/TypistTech/imposter/imposter's readme](https://github.com/TypistTech/imposter/](https://github.com/TypistTech/imposter/) for more details. |
| 116 | |
| 117 | ### How about not hooking into composer commands? |
| 118 | |
| 119 | Use [](https://github.com/TypistTech/imposter/imposter](https://github.com/TypistTech/imposter/](https://github.com/TypistTech/imposter/) directly. |
| 120 | |
| 121 | ### Do you have real life examples that use this composer plugin? |
| 122 | |
| 123 | Here you go: |
| 124 | |
| 125 | * [](https://github.com/Typisttech/sunnySunny](https://github.com/Typisttech/sunny](https://github.com/Typisttech/sunny) |
| 126 | * [](https://github.com/TypistTech/wp-cloudflare-guardWP Cloudflare Guard](https://github.com/TypistTech/wp-cloudflare-guard](https://github.com/TypistTech/wp-cloudflare-guard) |
| 127 | |
| 128 | |
| 129 | *Add your own [](https://github.com/TypistTech/imposter-plugin/edit/master/README.mdhere](https://github.com/TypistTech/imposter-plugin/edit/master/README.md](https://github.com/TypistTech/imposter-plugin/edit/master/README.md)* |
| 130 | |
| 131 | ### Which composer versions are supported? |
| 132 | |
| 133 | Both v1 and v2. |
| 134 | |
| 135 | ### Will you add support for older PHP versions? |
| 136 | |
| 137 | Never! This plugin will only work on [](https://secure.php.net/supported-versions.phpactively supported PHP versions](https://secure.php.net/supported-versions.php](https://secure.php.net/supported-versions.php). |
| 138 | |
| 139 | Don't use it on **end of life** or **security fixes only** PHP versions. |
| 140 | |
| 141 | ### It looks awesome. Where can I find some more goodies like this |
| 142 | |
| 143 | - Articles on [](https://typist.techTypist Tech's blog](https://typist.tech](https://typist.tech) |
| 144 | - [](https://profiles.wordpress.org/tangrufus#content-pluginsTang Rufus' WordPress plugins](https://profiles.wordpress.org/tangrufus#content-plugins](https://profiles.wordpress.org/tangrufus#content-plugins) on wp.org |
| 145 | - More projects on [](https://github.com/TypistTechTypist Tech's GitHub profile](https://github.com/TypistTech](https://github.com/TypistTech) |
| 146 | - Stay tuned on [](https://typist.tech/go/newsletterTypist Tech's newsletter](https://typist.tech/go/newsletter](https://typist.tech/go/newsletter) |
| 147 | - Follow [](https://twitter.com/TangRufusTang Rufus' Twitter account](https://twitter.com/TangRufus](https://twitter.com/TangRufus) |
| 148 | - **Hire [](https://typist.tech/contactTang Rufus](https://typist.tech/contact](https://typist.tech/contact) to build your next awesome site** |
| 149 | |
| 150 | ### Where can I give 5-star reviews? |
| 151 | |
| 152 | Thanks! Glad you like it. It's important to let me knows somebody is using this project. Please consider: |
| 153 | |
| 154 | - [](https://twitter.com/intent/tweet?url=https%3A%2F%2Fgithub.com%2FTypistTech%2Fimposter-plugin&via=tangrufus&text=Imposter%20Plugin%20-%20Composer%20plugin%20that%20wraps%20all%20%23composer%20vendor%20packages%20inside%20your%20own%20namespace.%20Intended%20for%20%23WordPress%20pluginstweet](https://twitter.com/intent/tweet?url=https%3A%2F%2Fgithub.com%2FTypistTech%2Fimposter-plugin&via=tangrufus&text=Imposter%20Plugin%20-%20Composer%20plugin%20that%20wraps%20all%20%23composer%20vendor%20packages%20inside%20your%20own%20namespace.%20Intended%20for%20%23WordPress%20plugins](https://twitter.com/intent/tweet?url=https%3A%2F%2Fgithub.com%2FTypistTech%2Fimposter-plugin&via=tangrufus&text=Imposter%20Plugin%20-%20Composer%20plugin%20that%20wraps%20all%20%23composer%20vendor%20packages%20inside%20your%20own%20namespace.%20Intended%20for%20%23WordPress%20plugins) something good with mentioning [](https://twitter.com/tangrufus@TangRufus](https://twitter.com/tangrufus](https://twitter.com/tangrufus) |
| 155 | - � |
| 156 | star [](https://github.com/TypistTech/imposter-pluginthe Github repo](https://github.com/TypistTech/imposter-plugin](https://github.com/TypistTech/imposter-plugin) |
| 157 | - [](https://github.com/TypistTech/imposter-plugin/subscription👀 watch](https://github.com/TypistTech/imposter-plugin/subscription](https://github.com/TypistTech/imposter-plugin/subscription) the Github repo |
| 158 | - write tutorials and blog posts |
| 159 | - **[](https://www.typist.tech/contact/hire](https://www.typist.tech/contact/](https://www.typist.tech/contact/) Typist Tech** |
| 160 | |
| 161 | ## Testing |
| 162 | |
| 163 | ```bash |
| 164 | composer test |
| 165 | composer style:check |
| 166 | ``` |
| 167 | |
| 168 | ## Alternatives |
| 169 | |
| 170 | Here is a list of alternatives that I found. However, none of these satisfied my requirements. |
| 171 | |
| 172 | *If you know other similar projects, feel free to edit this section!* |
| 173 | |
| 174 | * [](https://github.com/coenjacobs/mozartMozart](https://github.com/coenjacobs/mozart](https://github.com/coenjacobs/mozart) by Coen Jacobs |
| 175 | - Works with PSR0 and PSR4 |
| 176 | - Dependency packages store in a different directory |
| 177 | |
| 178 | * [](https://github.com/humbug/php-scoperPHP Scoper](https://github.com/humbug/php-scoper](https://github.com/humbug/php-scoper) |
| 179 | - Prefixes all PHP namespaces in a file/directory to isolate the code bundled in PHARs |
| 180 | |
| 181 | ## Feedback |
| 182 | |
| 183 | **Please provide feedback!** We want to make this project as useful as possible. |
| 184 | Please [](https://github.com/TypistTech/imposter-plugin/issues/newsubmit an issue](https://github.com/TypistTech/imposter-plugin/issues/new](https://github.com/TypistTech/imposter-plugin/issues/new) and point out what you do and don't like, or fork the project and [](https://github.com/TypistTech/imposter-plugin/pulls/send pull requests](https://github.com/TypistTech/imposter-plugin/pulls/](https://github.com/TypistTech/imposter-plugin/pulls/). |
| 185 | **No issue is too small.** |
| 186 | |
| 187 | ## Security Vulnerabilities |
| 188 | |
| 189 | If you discover a security vulnerability within this project, please email us at [](mailto:imposter-plugin@typist.techimposter-plugin@typist.tech](mailto:imposter-plugin@typist.tech](mailto:imposter-plugin@typist.tech). |
| 190 | All security vulnerabilities will be promptly addressed. |
| 191 | |
| 192 | ## Credits |
| 193 | |
| 194 | [](https://github.com/TypistTech/imposter-pluginImposter Plugin](https://github.com/TypistTech/imposter-plugin](https://github.com/TypistTech/imposter-plugin) is a [](https://typist.techTypist Tech](https://typist.tech](https://typist.tech) project and maintained by [](https://twitter.com/TangRufusTang Rufus](https://twitter.com/TangRufus](https://twitter.com/TangRufus), freelance developer for [](https://www.typist.tech/contact/hire](https://www.typist.tech/contact/](https://www.typist.tech/contact/). |
| 195 | |
| 196 | Full list of contributors can be found [](https://github.com/TypistTech/imposter-plugin/graphs/contributorshere](https://github.com/TypistTech/imposter-plugin/graphs/contributors](https://github.com/TypistTech/imposter-plugin/graphs/contributors). |
| 197 | |
| 198 | ## License |
| 199 | |
| 200 | [](https://github.com/TypistTech/imposter-pluginImposter Plugin](https://github.com/TypistTech/imposter-plugin](https://github.com/TypistTech/imposter-plugin) is released under the [](https://opensource.org/licenses/MITMIT License](https://opensource.org/licenses/MIT](https://opensource.org/licenses/MIT). |
| 201 |