-
Notifications
You must be signed in to change notification settings - Fork 664
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Plugin loading #855
Plugin loading #855
Conversation
@muglug here's the draft I promised. It's quite rough around the edges at the moment, but shows the general direction I had in mind. |
I'll refrain from digging to deep, but I'm very on-board with command-line tools.
why not use the |
It's in todo ("ability to refer to plugins by package name (cli only)"). But if this is going to be used to manage non-composer plugins, there's also got to be a way to refer to plugins that are not packages. Since I don't want file names there, it leaves class names as the only choice. |
Ah sorry for missing that. I guess it's 100% fine to use either package name or classname there, as they can't overlap This wouldn't work with a phar, right? Current plugins don't either, but I'm not massively bothered |
I think it could be made to. Autoloading is functional in phar builds, so as long as interfaces used by plugin is not mangled by
Is it because their base class is prefixed? |
One point I'd like to decide before moving further is naming. How do we name this entire thing: "plugins", "extensions", "bundles", something else? "plugins" is currently ambiguous, as it refers both to old plugins as well to this new package based thing. My preference would be keep this named "plugins", add a |
Yeah, "plugins" is fine, I think. I don't know how many, if any, have implemented their own plugins outside of Vimeo, but this would be part of a V3 change if it broke them. |
Once your plugin is ready, it can go in https://github.com/psalm! |
@muglug Is it ok to promote |
79305b5
to
140bf35
Compare
2c6aace
to
13c67cc
Compare
806d9ea
to
7c04717
Compare
Skeleton plugin (usable with |
2b8f0ad
to
82a469b
Compare
82a469b
to
66a4942
Compare
@muglug I believe it's ready for merge. |
@weirdan great! I don’t have my computer with me for the next 24 hours, but I’ll review once I’m back |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Got back a little later than intended, I've left some suggestions for documentation.
On a first glance this looks good - would you be able to migrate the plugins in the examples
directory to the new format?
- dropped todos I'm not going to pursues - locked entry point to be a class implementing entry point interface
It mimics the way old plugins were registered in Psalm\Config, so handler classes extending Psalm\Plugin should be fully compatible with it. Since Psalm\Plugin-style plugin registration was moved to RegistrationSocket, LegacyPlugin now only load file-based plugins, so it was renamed to FileBasedPluginAdapter.
- Its subfolder is registered as a local composer package in the root composer.json, so it's directly installable with ``` composer require psalm/echo-checker-plugin ``` - Migration is trivial: drop the plugin into a separate folder, then add simple composer.json and the entry point class.
d182474
to
9f33edb
Compare
@muglug all done |
Awesome, thanks. I'm going to make this part of a 3.0 release together with the |
Just created my first composer plugin: https://github.com/psalm/phpunit-psalm-plugin It works! Thanks so much |
Status
Ready for merge. Outstanding todo items can be added in subsequent PRs
Overview
Plugin installation/distribution system that piggy-backs on composer infrastructure. Follow-up to #849
Screenshot
Details
Available commands for
psalm-plugin
psalm-plugin list
- lists available and enabled pluginspsalm-plugin enable 'Plugin\Class\Name'
- enables plugin (modifiespsalm.xml
)psalm-plugin disable 'Plugin\Class\Name'
- disables plugin (modifiespsalm.xml
)Discovering plugins
https://packagist.org/packages/list.json?type=psalm-plugin
Plugin installation
composer install plugin-vendor/plugin-package-name
Plugin authoring
composer create-project ...
): https://github.com/weirdan/psalm-plugin-skeletontype
field, which should containpsalm-plugin
string.extra.psalm.pluginClass
should refer to the name of the class implementingPsalm\PluginApi\PluginEntryPointInterface
<pluginClass class="Qualified\Class\Name"/>
to config filePsalm\PluginApi
namespace should be used to provide stable interfaces plugins can rely onSample plugin
Packagist: https://packagist.org/packages/weirdan/psalm-doctrine-collections
Git repo: https://github.com/weirdan/psalm-doctrine-collections
Todo
psalm-plugin
pluginClass
)Further development