Registering a Class in PIMPLE (Dependency Injection Container)

I have this Car class, it has no setters

$carObj = new Car($make, $color);

How would this be register it with PIMPLE?

use Pimple\Container;

$container = new Container();

$container['car'] = function ($c) {
    return new Car($c[$make, $color']);   **//This is not correct here**

Containers are for services. You would not use one for entities like Car. It is possible that you might make yourself a CarFactory service and register that.

More reading:

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.