-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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 naming convention RFC implementation (closes #8848) #8903
Conversation
docs/plugins/creating-plugin.rst
Outdated
@@ -64,11 +64,14 @@ to ensure your plugin's extraordinary quality. | |||
|
|||
Besides the way you are creating plugins (based on our skeleton or on your own), there are a few naming conventions that should be followed: | |||
|
|||
* Bundle class must have a ``Plugin`` suffix instead of ``Bundle`` in its name (e.g. InvoicePlugin). | |||
* Bundle class must have a ``Sylius`` prefix, and a ``Plugin`` suffix (instead of ``Bundle``) in its name (e.g. ``SyliusInvoicePlugin``). |
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.
I'd make it vendor name + Sylius
+ actual name + Plugin
. The reasoning behind it is to distinct official Sylius plugins from the community made ones. SyliusInvoicePlugin
uses sylius_invoice
as config root name, whereas AcmeSyliusInvoicePlugin
uses acme_sylius_invoice.
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.
True.. Downside is that e.g. in my case using my own name we get to something like this: StefanDoornSyliusInvoicePlugin
.. sounds silly :-) The vendor is already in the namespace and the repository is in another vendor, isn't that enough to make people (developers only) understand what the source of it is?
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.
These are only two files, bundle one and extension one, it's most likely to be an one time thing. The issue here is to have distinct config keys.
For Composer package name and Github repos it's already solved by prefixing with vendor-name/
.
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.
Ah that way. Ok, I'll check it. Alternative could be to adjust the trait to adjust the config key I think based on PSR4 namespace.
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.
Is there really a need to distinct official Sylius plugins from the community made plugins? There should be one rule for them all IMO.
And Sylius
+ name
+ Plugin
seems simple and enough.
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.
Using vendor names in package names / configuration keys is a common practice, I can't think of Symfony bundle which does not follow this convention.
Let's just take our most common plugin, CMS one, there's one from Lakion and one from BitBag. If we stay with SyliusCmsPlugin
, the configuration key will always be sylius_cms
, which might cause confusion. And then FriendsOfSylius or Sylius itself wants to unify them... creating another one with the same configuration key.
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.
I see the point. Is it possible to do this by adjusting the trait? What I'm trying is to get the name of the repo and the class name aligned, but having diversified configs keys :)
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.
As for the currently existing trait, changing its behaviour will be a BC break and having two of them might be misleading.
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.
Makes sense, not an option. Could you (@pamil, @pjedrzejewski, @CoderMaggie) let me know what the naming convention regarding this will be? Then I will implement accordingly.
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.
I guess we can end up with:
Composer package name: vendor-name/sylius-something-plugin
Bundle / extension classname: VendorNameSyliusSomethingPlugin
/ VendorNameSyliusSomethingExtension
- namespace does not matter, probably in VendorName\SyliusSomethingPlugin
docs/plugins/creating-plugin.rst
Outdated
* Bundle class must use the ``Sylius\Bundle\CoreBundle\Application\SyliusPluginTrait``. | ||
* The name of the extension in DependencyInjection folder must follow the regular Symfony rules (e.g. InvoiceExtension). | ||
* The plugin shouldn't have Sylius prefix in its name. ``Plugin`` suffix in terms of bundles is unique for Sylius at the moment. | ||
* The name of the extension in the DependencyInjection folder must follow the regular Symfony rules (e.g. ``SyliusInvoiceExtension``). |
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.
Then the extension name changes accordingly.
Changed a lot and added examples. Let me know what you think. |
2cc4b37
to
db122e6
Compare
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.
Looks awesome! Can you switch this PR's base branch to 1.0?
docs/plugins/creating-plugin.rst
Outdated
* Bundle class name should start with vendor name, followed by ``Sylius`` and suffixed by ``Plugin`` (instead of ``Bundle``), e.g.: ``VendorNameSyliusInvoicePlugin``. | ||
* Bundle extension should be named similar, but suffixed by the Symfony standard ``Extension``, e.g.: ``VendorNameSyliusInvoiceExtension``. | ||
* Bundle class must use the ``Sylius\Bundle\CoreBundle\Application\SyliusPluginTrait`` trait. | ||
* Namespace should follow _`PSR-4 <http://www.php-fig.org/psr/psr-4/>`. It should start with vendor name, followed by ``Sylius`` and suffixed by ``Plugin`` (e.g. ``VendorName\SyliusInvoicePlugin``) |
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.
It should start with vendor name, followed by Sylius
and suffixed by Plugin
(e.g. VendorName\SyliusInvoicePlugin
) -> Top-level namespace should be the vendor name and the second-level one should be prefixed with...?
docs/plugins/creating-plugin.rst
Outdated
The following rules are applied to all bundles which will provide an integration with the whole Sylius platform | ||
(``sylius/sylius`` or ``sylius/core-bundle`` in vendors). Reusable components for the whole Symfony community, which will be based | ||
just on some Sylius bundles should follow regular Symfony conventions. | ||
"autoload": { |
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.
The build is failing because the given JSON snippet is invalid, let's change it to:
{
"autoload": {
"psr-4": {
"VendorName\\SyliusInvoicePlugin\\": "src/",
"Tests\\VendorName\\SyliusInvoicePlugin\\": "tests/"
}
}
}
db122e6
to
8e1ee0d
Compare
8e1ee0d
to
d9e315d
Compare
@pamil I think we are good to go now. |
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.
Great one!
This one should be merged together with Sylius/PluginSkeleton#56. |
Thank you very much Stefan! 👍 Great work. |
@@ -11,11 +11,11 @@ which has built-in infrastructure for designing and testing using `Behat`_. | |||
|
|||
.. code-block:: bash | |||
|
|||
$ composer create-project sylius/plugin-skeleton MyPlugin | |||
$ composer create-project sylius/plugin-skeleton SyliusMyFirstPlugin |
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.
did you intentional leave out the vendor name here?
I noticed that the conventions do not see to cover DI service as well as command names. Should this maybe be covered as well? |
After discussion in #8848, hereby the PR. Difference from the discussion is that I've chosen to name the repository after the class bundle name, to have it all consistent and in the same style.
Before merging this, there should also come a PR to the PluginSkeleton to rename things I think.