zeuxisoo / php-slim-whoops

PHP whoops error on slim framework
132 stars 10 forks source link

Use ContainerInterface and support different kind of containers #18

Closed SpazzMarticus closed 7 years ago

SpazzMarticus commented 7 years ago

Hi, I noticed that your code uses ArrayAccess to get and set dependencies from the container. Slim allows for any ContainerInterface and I wanted to use PHP-ID which does not implement ArrayAccess any more. Instead it uses set().

The ContainerInterface only defines get(<id>) and has(<id>) so I changed all occurrences of getting dependencies from the container from $container[<id>] to $container->get(<id>)

For setting phpErrorHandler, errorHandler, whoops I added a check: If the container implements ArrayAccess it is used to set the dependencies, if not a callback is executed. I figured that

$container->set(<id>,<value>);

should be enough for most of the simple containers out there.

If you need a custom callback you can set it with setContainerSetImplementation(<callback>).