A ideia for slim4:
Should slim4 have a ServiceProviderInterface for registering services in the container?

A ServiceProvider would serve the pourpose to register services in the container and boot them up and unlike middleware is not intended to change the response neither is dependent on the request.

namespace Slim\Interfaces;

interface ServiceProviderInterface
public static function register();
public static function boot();

We should have a way to register a provider globally for a single route or a route group just like the middleware

// register globally (for all routes)

$app->register(new \App\ServiceProviders\ProviderA);

// register for a single route

$app->get('/hello/{name}', function (Request $request, Response $response, array $args) {
    $response->getBody()->write("Hello, $name");

    return $response;
})->register(new \MyApp\ServiceProviders\ProviderA);

// register for a route group

$app->group('', function() {
    $this->get('/billing', function ($request, $response, $args) {
        // Route for /billing
    $this->get('/invoice/{id:[0-9]+}', function ($request, $response, $args) {
        // Route for /invoice/{id:[0-9]+}
})->register(new \MyApp\ServiceProviders\ProviderA);



I am not sure what you are saying here. But Slim 4 will not include a container by default, you will be free to add your own as you see fit.