src/ContentNegotiationServiceProvider.php
public function register(Container $app)
    {
        $app["conneg.responseFormats"] = array("html");
        $app["conneg.requestFormats"] = array("form");
        $app["conneg.defaultFormat"] = "html";

        $app["conneg"] = function (Container $app) {
            if ($app->offsetExists("serializer")) {
                if ($app["serializer"] instanceof JMS\Serializer) {
                    if (!$app->offsetExists("conneg.serializationContext")) {
                        $app["conneg.serializationContext"] = null;
                    }
                    if (!$app->offsetExists("conneg.deserializationContext")) {
                        $app["conneg.deserializationContext"] = null;
                    }

                    return new JmsSerializerContentNegotiation($app);
                } elseif ($app["serializer"] instanceof SymfonySerializer\Serializer) {
                    if (!$app->offsetExists("conneg.serializationContext")) {
                        $app["conneg.serializationContext"] = array();
                    }
                    if (!$app->offsetExists("conneg.deserializationContext")) {
                        $app["conneg.deserializationContext"] = array();
                    }

                    return new SymfonySerializerContentNegotiation($app);
                }
            }

            throw new ServiceUnavailableHttpException(null, "No supported serializer found");
        };
    }
public function register(Container $app)
    {
        $app["conneg.responseFormats"] = array("html");
        $app["conneg.requestFormats"] = array("form");
        $app["conneg.defaultFormat"] = "html";

        $app["conneg"] = function (Container $app) {
            if ($app->offsetExists("serializer")) {
                if ($app["serializer"] instanceof JMS\Serializer) {
                    if (!$app->offsetExists("conneg.serializationContext")) {
                        $app["conneg.serializationContext"] = null;
                    }
                    if (!$app->offsetExists("conneg.deserializationContext")) {
                        $app["conneg.deserializationContext"] = null;
                    }

                    return new JmsSerializerContentNegotiation($app);
                } elseif ($app["serializer"] instanceof SymfonySerializer\Serializer) {
                    if (!$app->offsetExists("conneg.serializationContext")) {
                        $app["conneg.serializationContext"] = array();
                    }
                    if (!$app->offsetExists("conneg.deserializationContext")) {
                        $app["conneg.deserializationContext"] = array();
                    }

                    return new SymfonySerializerContentNegotiation($app);
                }
            }

            throw new ServiceUnavailableHttpException(null, "No supported serializer found");
        };
    }
Set defaults and build the conneg service.

@param Container $app
@throws ServiceUnavailableHttpException