dingo / api

A RESTful API package for the Laravel and Lumen frameworks.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Custom Response Formats not work with lumen 6.x

ALTELMA opened this issue · comments

Q A
Bug? no
New Feature? no
Framework Lumen
Framework version 6.x
Package version 2.4
PHP version 7.4

Actual Behaviour

I try to upgrade the version of the lumen from 5.2 to 6.0, now I struggle with a custom response.
I use the same code from the old version, but always got an error message like below.

Unable to format response according to Accept header.

I try google to find a way to What I miss or do wrong steps.

Expected Behaviour

The custom response should work the same code before.

Steps to Reproduce

  1. Install new Lumen 6.0
  2. Install Dingo
    image

image

I put this one in bootstrap/app.php

Dingo\Api\Http\Response::addFormatter('myJsonFormatter', new App\Formatters\myJsonFormmater);

Look like this config not load in the controller as well. When I put it in controller working.

Please help me to suggest :)

Anyone can help me?

commented

Not really sure, I recommend switching to Laravel, as Lumen is not overly supported.

I already fix my issue now. Root cause come from legacy app build by Lumen 5.2 and put addFotmat in bootstrap file. It works on 5.2, but in 6.x should put in any servicr provider instead.

Anyway, in bootstrap file should register service provider from dingo before service provider contains addFotmat.