Return value must be of type Psr\Http\Message\ResponseInterface, null returned

This public forum is for user-to-user discussions of PHPMaker. Note that this is not support forum.
Post Reply
malik
User
Posts: 6

Return value must be of type Psr\Http\Message\ResponseInterface, null returned

Post by malik »

Hi
I am using PHPMaker v2024.9.0
I have a problem when uploading project files to the server.
This problem occurs when creating a new table on a database and generating all files.
These [list/add/edit/delete] pages not working on the browser and get this error 404 Not Found.
When I tried to build a custom file and generate all files the same error occurred 404 Not Found.

Notes 1: for old tables and custom files pages there are no problems it works well, and when testing the project locally it works well.

Notes 2:
I tried to change the code on the routes.php file and wrote a function like this:

$app->map(
    ["GET", "POST", "PUT", "DELETE", "PATCH"], 
    '/{routes:.+}', 
    function ($request, $response, array $params) {}
);

instead of this function :

$app->map(
    ["GET", "POST", "PUT", "DELETE", "PATCH"],
    '/{routes:.+}',
    fn($request, $response, $params) => throw new HttpNotFoundException($request, str_replace("%p", $params["routes"], Container("app.language")->phrase("PageNotFound")))
);

I get this error:
vendor/slim/slim/Slim/Handlers/Strategies/RequestResponse.php(38): Slim\Handlers\Strategies\RequestResponse::__invoke(): Return value must be of type Psr\Http\Message\ResponseInterface, null returned

PHPMaker v2024.9.0
PHP version 8.2.6
webserver Apache

Thank you


arbei
User
Posts: 9384

Post by arbei »

malik wrote:

vendor/slim/slim/Slim/Handlers/Strategies/RequestResponse.php(38): Slim\Handlers\Strategies\RequestResponse::__invoke(): Return value must be of type Psr\Http\Message\ResponseInterface, null returned

As the error says, your function must return $response, you cannot return nothing.


malik
User
Posts: 6

Post by malik »

I changed the code in routes.php file just for do debuging.
Before chenged the code the error was 404 Not Found.
Even I generate all files I still get the same error
404 Not Found. just for new added tabals or custom files, the old pages it work well.


arbei
User
Posts: 9384

Post by arbei »

Read Use route cache:
When you deploy new versions of your scripts (for example, after adding or deleting a table) to production, you must delete the generated file (<ProjectFolder>/<LogFolder>/cache/RouteCache.php) to ensure that the cache will be re-compiled.


malik
User
Posts: 6

Post by malik »

thank you
it work finally
my fault was when upload project files to server
I upload all files except cache folder in log folder


Post Reply