How to scope only user-defined namespaces?
AndriyHudyma opened this issue · 4 comments
Hi! Is there an easy way to scope only those namespaces that are user-defined?
In another words, currently we have a feature that allows to scope "all namespaces, with exception of those that are on the list"
Is there a feature to scope "no namespaces, but only those that are on the list"?
Thanks!
Hi!
Is there a feature to scope "no namespaces, but only those that are on the list"?
Not really, because the goal is to scope as much as possible not vice-versa.
Is there an easy way to scope only those namespaces that are user-defined?
I'm not sure to understand that part: any non-core code is user-defined and the non-core code should not be scoped already
Thanks for your response!
Let me describe the use case when we need to scope only listed namespaces.
A plugin for CMS system:
- Can use some dependencies from that CMS taking them from /vendor folder located in root folder of the project.
- Can have its own namespaces.
- Can have its own dependencies located in local (plugin specific) /vendor folder.
There could be multiple plugins and we would like to ensure that there are no namespaces collision.
We don't need to scope dependencies from CMS, because they are unique.
We don't need to scope our plugin own namespaces, because they have unique plugin vendor prefix.
But we need to scope plugin's dependencies, because it could happen that two different plugins using the same package.
That's were 'scope only listed namespaces' feature can help. Or scope 'only namespaces from specified vendor folder' feature.
Of course, there is another way - just scope all namespaces. This will work. However, what if all plugins are using some heavy package that already present in CMS anyway? Like Laravel's Eloquent. We will need to put that package in each plugins vendor folder, which is not ideal.
Yeah, this feature request is also needed for WordPress plugin environment. I want to add PHP-Scoper to my open-source project WP React Starter. I want to prefix only a given list of namespaces so e. .g WordPress functions and classes are not prefixed. Is this somehow possible?
@matzeeable sorry for the late reply. It is not currently possible but should be doable via #303 (comment)