typisttech/imposter-plugin
Composer plugin that wraps all composer vendor packages inside your own namespace. Intended for WordPress plugins
Installs: 19 815
Dependents: 2
Suggesters: 8
Stars: 5
Watchers: 2
Forks: 1
Open Issues: 0
Type:composer-plugin
Requires
- php: ^7.0
- composer-plugin-api: ^1.1
- typisttech/imposter: ^0.3.0
Requires (Dev)
- codeception/base: ^2.3
- composer/composer: ^1.5
- squizlabs/php_codesniffer: ^3.2
- typisttech/codeception-composer-project-module: ^0.1.1
README
Wrapping all composer vendor packages inside your own namespace. Intended for WordPress plugins. Imposter Plugin is a composer plugin wrapper for Imposter.
- Why?
- Install
- Usage
- Frequently Asked Questions
- What can I find out more information?
- Does Imposter Plugin support
PSR4
,PSR0
,Classmap
andFiles
? - Does Imposter Plugin support
exclude-from-classmap
? - How about
require-dev
packages? - How about PHP built-in classes?
- How about packages that don't use namespaces?
- How about packages that use fully qualified name?
- Do you have real life examples that use this composer plugin?
- Support!
- Alternatives
- Developing
- Running the Tests
- Feedback
- Change log
- Security
- Contributing
- Credits
- License
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
Note: You need to run $ composer dump-autoload
after this command.
This command:
- Look for
/path/to/project/root/composer.json
- Find out vendor-dir
- Find out all required packages, including those required by dependencies
- Find out all autoload paths for all required packages
- Prefix all namespaces with the imposter-plugin namespace defined in your
composer.json
Before:
<?php namespace Dummy\File; use AnotherDummy\{ SubAnotherDummy, SubOtherDummy }; use Dummy\SubOtherDummy; use OtherDummy\SubOtherDummy; use RuntimeException; use \UnexpectedValueException; class DummyClass { }
After:
<?php 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
Support!
Donate
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
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
Developing
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
.
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.
Contributing
Please see CONTRIBUTING and CODE_OF_CONDUCT for details.
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.