Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Slim in PHP 8.1: site returns error #3143

Closed
taylorren opened this issue Jan 25, 2022 · 2 comments
Closed

Slim in PHP 8.1: site returns error #3143

taylorren opened this issue Jan 25, 2022 · 2 comments

Comments

@taylorren
Copy link

I have been using Slim PHP framework to provide my API service (https://api.rsywx.com).

Recently, I updated my PHP to 8.1 and when I visited the site, it gives the following error:

{
    "statusCode": 500,
    "error": {
        "type": "SERVER_ERROR",
        "description": "ERROR: Return type of App\\Application\\Actions\\ActionPayload::jsonSerialize() should either be compatible with JsonSerializable::jsonSerialize(): mixed, or the #[\\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice on line 67 in file \/home\/tr\/www\/api.rsywx.com\/src\/Application\/Actions\/ActionPayload.php."
    }
}

I have not changed anything in my source code, so I guess the problem raises from Slim framework itself.

Any hints to solve this issue?

@odan
Copy link
Contributor

odan commented Jan 26, 2022

At first, I thought it could be a bug, but Slim does not do any JSON encoding etc.

I assume this is a PHP 8.1 deprecation in your code:

See this: https://3v4l.org/Fon9f#v8.1.2
vs.
this: https://3v4l.org/gqeus#v8.1.2

Please try to add : mixed as return type in file ActionPayload.php on line 67.

@l0gicgate
Copy link
Member

This is a Slim-Skeleton issue that's been fixed.

See slimphp/Slim-Skeleton#252

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants