Skip to content
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

Doesn't work with older versions of Laravel due to Collection namespace collision #46

Open
ghost opened this issue Sep 14, 2017 · 3 comments

Comments

@ghost
Copy link

ghost commented Sep 14, 2017

This may be entirely to do with some oddity of the project where I'm trying to switch to Zttp (Lumen v5.1.7, due to requirements back when it was built and lack of time/resources to rework it in 5.5 or full Laravel), but the changes in runBeforeSendingCallbacks in commit 7b6dddc throw an error for me on any request, including a simple get with no parameters:

$response = Zttp::get('https://github.com');

PHP error: Undefined property: Illuminate\Support\Collection::$each in [...]/vendor/kitetail/zttp/src/Zttp.php on line 178

Using kitetail/zttp v0.3.0 and illuminate/support v5.1.41.
Illuminate\Support\Collection definitely has the each function, but I'm probably in over my head as to what I'm doing wrong. If I switch back to array_reduce and [] instead of collect(), there are no errors and the call behaves as expected. Any idea what I'm running up against? Again, fully expecting it to be something on my end (and I'm not expecting help with that) with the older Lumen/Illuminate versions in play rather than a Zttp issue, but I figured I could check.

@adamwathan
Copy link
Contributor

I bet this is because we use the collect helper function and Lumen already has it defined so we are getting an old version of the Collection class. Not at my computer right now but I'll double check this when I get home 👍🏻

@adamwathan
Copy link
Contributor

So the issue is unfortunately somewhat complex, I've opened an issue on the package we use with more details:

tighten/collect#54

I'm going to rename this issue to match the root cause and will think if there's a good interim solution.

@adamwathan adamwathan changed the title runbeforeSendingCallbacks errors on undefined each Doesn't work with older versions of Laravel due to Collection namespace collision Sep 14, 2017
@dakira
Copy link

dakira commented Feb 19, 2018

I ran into this on a pretty blank API project that had laravel/tinker in its dependencies. Tinker apparently installed illuminate/support v 5.2.x when depending on the latest tinker.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants