-1

In spite that I am very new to the Slim 3 framework I'm using it for a small project (API) and it works fine except for the double output that I'm getting back and it's making me crazy! I'm suspecting that htaccess is calling the index.php file twice, leading the app to run more than once, or an incorrect integration of the viewer code (Formater.php)....but I can't seem to find it.

My second question is: Where exactly do Slim 3 apps end ( the exit point ) ?

Here is a short description of my app flow:

input-request ---> Slim route handlers ---> my code (middleware and controllers ) ---> my output formater ( I use a small class to handle the output depending on the format switch [text, json, xml] *** the Formater class)

This is my app.php file

Routes.php

MainGetController.php -- an example of how I pass output to the formater

htaccess

output example as show by postman

Makoto
  • 104,088
  • 27
  • 192
  • 230
  • Sorry, the wrong file was uploaded for the MainGetController.php here is the code: namespace App\Controllers; class MainGetController extends Controller{ public function Dispatch($request, $response, $args){ global $Config; $this->ControllerParse(__CMD_VIEW__); return $this->view->render($response);} – Acute Club Aug 02 '18 at 00:16
  • As an FYI for next time, you're going to want to paste your actual code, not pictures. – Makoto Aug 03 '18 at 21:52
  • pasting pics instead of text takes more time and effort than just the code. I did it for readability purposes with all those colors and such....but next time will do it the easy way and paste just the code. – Acute Club Aug 04 '18 at 15:18

1 Answers1

0

OK, I have taken some more time to read the source code of the Slim Response files and found that I had to use the response->getBody()->rewind() method to start with a fresh response body in case you are using your own viewer..... Indeed that did solve the problem.