typisttech/imposter-plugin
Composer 安装命令:
composer require typisttech/imposter-plugin
包简介
Composer plugin that wraps all composer vendor packages inside your own namespace. Intended for WordPress plugins.
README 文档
README
Imposter Plugin
Composer plugin that wraps all composer vendor packages inside your own namespace. Intended for WordPress plugins.
Built with ♥ by Typist Tech
Imposter Plugin is an open source project and completely free to use.
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:
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:
- A Narrative of Using Composer in a WordPress Plugin
- A Warning About Using Composer With WordPress
- Plugin Dependencies (Yet Another Plugin Dependencies Ticket)
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.
Typist Tech is ready to build your next awesome WordPress site. Hire us!
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:
- looks for
/path/to/project/root/composer.json - finds out vendor-dir
- finds out all required packages, including those required by dependencies
- finds out all autoload paths for all required packages
- 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.
- Imposter run twice when
composer installandcomposer update - Traits are not transformed
- 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.
How to distrube impostified plugins?
- Switch to the lowest PHP version you support
- Install dependencies
$ composer install --no-dev --classmap-authoritative --prefer-dist
- Clean up the source code, e.g: remove test files
- Zip the source code. Tips: Use
$ composer archive - Send the zip to others / Commit to wp.org SVN. Tips:
How to install impostified plugins via composer?
Impostified plugins are meant to be commited to wp.org svn.
Using imposter means you forgo the ability to install the plugins with composer directly via packagist.org or VCS (even with type: wordpress-plugin in composer.json).
To composer require impostified plugins, use wpackagist.org.
The whole imposter situation is horrible. What can we do about it?
Until WordPress core comes up with a solution on dependency managment, keep clam and carry on.
In the meantime, checkout these tools to make WordPress suck less modernizing WordPress development:
- bring OOP into WordPress
- leveraging development practices from other languages and ecosystems, and applying them to WordPress
Do you have real life examples that use this composer plugin?
Here you go:
Add your own here
Which composer versions are supported?
Both v1 and v2.
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
- Articles on Typist Tech's blog
- Tang Rufus' WordPress plugins on wp.org
- More projects on Typist Tech's GitHub profile
- Stay tuned on Typist Tech's newsletter
- Follow Tang Rufus' Twitter account
- Hire Tang Rufus to build your next awesome site
Where can I give 5-star reviews?
Thanks! Glad you like it. It's important to let me knows somebody is using this project. Please consider:
- tweet something good with mentioning @TangRufus
- ★ star the Github repo
- 👀 watch the Github repo
- write tutorials and blog posts
- hire Typist Tech
Testing
composer test
composer style:check
Alternatives
Here is a list of alternatives that I found. However, none of these 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
-
- Prefixes all PHP namespaces in a file/directory to isolate the code bundled in PHARs
Feedback
Please provide feedback! We want to make this project as useful as possible. Please submit an issue and point out what you do and don't like, or fork the project and send pull requests. No issue is too small.
Security Vulnerabilities
If you discover a security vulnerability within this project, please email us at imposter-plugin@typist.tech. All security vulnerabilities will be promptly addressed.
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
Imposter Plugin is released under the MIT License.
typisttech/imposter-plugin 适用场景与选型建议
typisttech/imposter-plugin 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 264.12k 次下载、GitHub Stars 达 157, 最近一次更新时间为 2017 年 03 月 21 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「dependency」 「composer」 「wordpress」 「namespace」 「composer-plugin」 「monkey-patching」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 typisttech/imposter-plugin 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 typisttech/imposter-plugin 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 typisttech/imposter-plugin 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
A fast and intuitive dependency injection container.
This composer plugin enables installation of GravityForms WordPress plugin and its addons.
Simple ASCII output of array data
Dependency injection container for the Monolith framework.
Http Microframework for Hack
统计信息
- 总下载量: 264.12k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 158
- 点击次数: 30
- 依赖项目数: 2
- 推荐数: 8
其他信息
- 授权协议: MIT
- 更新时间: 2017-03-21