-
Notifications
You must be signed in to change notification settings - Fork 430
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
Autoloader loaded twice causing errors #91
Comments
The Maybe in your case it is better to install GrumPHP globally? Than it would use the autoloader of the current package + the global autoloader. |
@lykciv Does the answer solve your issue? I don't think there is anything we can do about this. |
Thank you for your feedback. I've installed grumphp globally, but unfortunately it doesn't solve my problem. The project autoloader is still used.
A possible solution would be to process the local and global autoloaders separately and do something like this:
|
That won't resolve the actual issue: One other option could be to add an environment variable like |
Someone from our team had this issue as well, any news on this? |
Currently there is no progress on this issue. |
the check should be for |
There is nothing wrong with duplicate autoloading. It is perfectly possible that you want to load both the globally installed packages + the framework specific packages. For classes this isn't a big issue since composer is smart enough to autoload them. Howerver, it is possible that 2 complete different versions of the same dependency are installed, which might cause errors. The problem is with functions. Normally the package should check if the function already exists instead of just autoloading the functions. A good example on how to do this: https://github.com/symfony/polyfill-php71/blob/master/bootstrap.php I would always recommend running grumphp in project mode and remove the globally installed version. It doesn't really add much value when it's installed globally in my opninion. |
it might depend on the case, if the 2 files are identical whether or not - because if both are the same version, one can already skip on file access. most granular might be an option to prefer global / local classes, if such a use case should exist. |
Since the path system got a rewrite in #644 which has better autolaoding support, I am closing this issue for now. |
I'm currently working on a package within the vendor folder of a project. So, if I run grumphp, the following autoloaders are loaded:
This is causing errors when using the package
beberlei/assert
in both the package and the project.The following fixes the error, but I noticed the
break
was removed in this commit (b23f63c).Full output of the error:
The text was updated successfully, but these errors were encountered: