Page 1 of 1

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

Posted: Mon Mar 18, 2024 3:55 pm
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


Re: New tables and pages not work on the server

Posted: Mon Mar 18, 2024 3:59 pm
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.


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

Posted: Mon Mar 18, 2024 11:15 pm
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.


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

Posted: Tue Mar 19, 2024 9:58 am
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.


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

Posted: Tue Mar 19, 2024 5:42 pm
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