Be compatible with Laravel 5.4
Closed this issue · 9 comments
Hi,
With L5.4, the app()->make()
does not longer support 2 arguments.
You can't pass parameters to bind()
anymore.
So the package isn't compatible with this new version.
We have many choices for that, according laravel/framework#17556
Edit: Also here laravel/ideas#391
The standard answer is to "make a factory" but.. this is already one !
So, I'm to just call new Clients in the factory without the container's make method:
But we loose the pubsub.xxx_client
aliases (I personally don't care about that, but maybe someone use them ?) and tests are more difficults to do.
I've started to made the modification on local, and can PR it if you want (I'm just wondering about the tests..).
Or maybe we can find an other better way..?
Thanks
In fact the role of the factory is to transform config, and pass it to a new valid Google/Redis/xxx object. So, in the tests, we should check that the object is really valid, and it received the proper configuration. By mocking the creation as actual, we don't test if the client was created properly.
I think this is the reason why the make -with-arguments method was considerated as a code smell.
Thanks for reporting this.
We'll take a look and see if there's a neater way of constructing these objects without passing in custom configuration.
Guys ? Some news ?
HI @mathieutu. I am actually struggling a lot with this at the moment. You can see I asked the question on the internals channel.
I made a branch so long to try out a couple of things. I wanted to keep the nice aliases but also extract the configs for each dependency out. In the process of designing like a configuration provider type class that knows how to transform the dependencies for those three affected clients, redis
, google pubsub
and kafka
but its proving hard because essentially we are ending up with a FactoryFacotry
and that it the real code smell imho.
You can see in the comparison, the road that I want to take but I am hitting a wall where the config that the client needs to be initialised with is now not really testable.
What are your thoughts?
Hi @etiennemarais!
I understand your problem. In fact as I said I think we should test the real object, created by the factory, and don't mock it. You pass a conf, and check at the end if it's a proper instance, an if it have the proper conf.
But, even if I think this could be better, @taylorotwell made a PR with a makeWith
method which we will be alble to use soon, so problem will be solved anyway...
Ye I saw that post he made on the internals main issue. I will make a PR this weekend to take a run at the config closure passing which is actually not too bad imo. We can review it together and make a call.
Good news, Taylor implemented a makeWith
method to bring back the old functionality. See Pull request. I will spend some time today to swap this out, or if you want make a PR @mathieutu then I will merge it in. It seems like this issue affected so many people that it worked in getting it back.
Yep ! It's what I told you here : #6 (comment)
Ok, I'm a bit busy right now, but the first one with time make the PR make it, and warn the other on!
:)
Thanks for the PR.
This is published in 2.0.3