-
Notifications
You must be signed in to change notification settings - Fork 367
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
Two Plugin with same namespace #7
Comments
Look at the lesson (WordPress Plugin Development - Part 10 - Namespaces and Composer Autoload ) https://www.youtube.com/watch?v=nbF4hWJ1hJA. It will explain everything. |
I went through the video and have gone through again. The video explains how to use the namespace through composer autoload and it's well explained. My plugin works well. Only gets broken when two custom plugin get installed (after activated) together. Because both are using "Inc" namespace. |
Exactly change the namespace of one in composer on the PSR-4 line and do a
composer dump-autoload
|
Ok then what if my plugin installed in a website where already a plugin using the same namespace. |
You are right. I deregistered all my services, changed initial file names in plugin folder, namespace and did a whole new composer install and something still duplicated. |
Shadhin...Thanks for your explanation on 1/8/219 of the exact problem I was having. Using the ideas above I changed the inc directory to my plugin name + Inc, changed globally (in the plugin) namespace Inc to namespace my plugin name + Inc, changed globally use Inc to use my plugin name + Inc, and in the main plugin PHP changed the activate, deactivate and Init (2 places) Inc to my plugin name + Inc. I then changed the psr-4 line in composer.json to read "psr-4": { " My plugin Name + Inc \" : "./ My plugin Name + Inc" } and ran composer dump-autoload. I now have three plugins operating independently with no collisions. Thanks to you all!!! |
Just found this issue too. Did a global Find/Replace with this regex in the new/modified plugin based on the Alecaddd model. Thanks for asking this question, @shadhin-msa . The next question is, what do we do with critical information like this? Add it to the README.md? Add it to a wiki? If this valuable Issue is closed, others lose the benefit of the solution. |
Hi there,
Thanks for your awesome youtube series.
The issue is,
In your plugin, you used "Inc" namespace. What if another plugin uses same "Inc" namespace through composer?
I faced the issue. it loads files from one of the repositories src for both plugins. So one plugin gets broken.
A possible solution could be using a unique identifier for the namespace. But it's not the appropriate solution, is it?
Any solution?
The text was updated successfully, but these errors were encountered: