You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The strauss package is working perfectly for prefixing classes and constants. So far it helps us avoiding dependency hell within our custom WordPress plugin and we prevented a lot of compatibility issues with other plugins.
But I'm running into an issue. The illuminate\collections is being used and this package loads global functions in the helpers.php. Which is checking if a function exist like in this example:
if (! function_exists('collect')) {
/** * Create a collection from the given value. * * @param mixed $value * @return \Custom\Prefix\Illuminate\Support\Collection */functioncollect($value = null)
{
returnnewCollection($value);
}
}
But when a different plugin is using the same package and this plugin is loaded first; we end up in the global function of that plugin. Which is not using my custom prefixed package and which is not using the same version as we do in our plugin.
We have a similar problem with the template engine Twig. They declare global functions, with a twig_ prefix. The issue here is a bit different, since Twig doesn't do function_exists checks before defining global functions.
We resolved the issue for now with a global search & replace in the code base that prefixes the functions (twig_cycle --> some_prefix_twig_cycle), but it would be great to have a better solution included in this package.
The strauss package is working perfectly for prefixing classes and constants. So far it helps us avoiding dependency hell within our custom WordPress plugin and we prevented a lot of compatibility issues with other plugins.
But I'm running into an issue. The illuminate\collections is being used and this package loads global functions in the helpers.php. Which is checking if a function exist like in this example:
But when a different plugin is using the same package and this plugin is loaded first; we end up in the global function of that plugin. Which is not using my custom prefixed package and which is not using the same version as we do in our plugin.
This is resulting in this error:
This is my composer.json:
I'm using the strauss.phar at the moment. Is there a way to support prefixing global functions?
The text was updated successfully, but these errors were encountered: