lets say i have a service:
namespace Helloworld\\Service;
class GreetingService
{
public function getGreeting()
{
if(date(\"H\") <= 11)
I think the second approach is better, which is making the controller class independent to the GreetingService. This approach will be useful when you want to use another greeting service to be consumed by the controller. You don't need to change the code in controller class at all, instead you do that by changing the service manager with that factory closure.
I believe this is the main idea of inversion of control or dependency injection, all wiring and configuration are done outside the class (in this case: controller class).
So, in my opinion, that's the reason why the second approach is the better one.