Support the ongoing development of Laravel.io →
posted 8 years ago
Architecture

In the Laravel 5.4 Upgrade Guide it states:

The container's make method no longer accepts a second array of parameters. This feature typically indicates a code smell. Typically, you can always construct the object in another way that is more intuitive. Does anybody know what the "more intuitive" way is?

For example, I have code that needs to instantiate an object that may depend on other classes but also on some data such as an Eloquent object so I just do something like:

$transformer = App::make('PostTransformer::class', [$post]);

If I can no longer pass the second array of parameters, what should I do? Is the best solution to just add a setPost() method to set the post after instantiating the object?

Last updated 3 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

ejunker ejunker Joined 25 Apr 2014

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2025 Laravel.io - All rights reserved.