Slim Framework call a slim function from another function in different php page

php, slim

Solution

Hello I have this in my production app.

Signature of route:

$app->get('xxx/:jobid', function ($jobid) use($app) {})->name('audit_edit');


//Get The Route you want... 
$route = $app->router()->getNamedRoute("audit_edit"); //returns Route
$route->setParams(array("jobid" => $audit->omc_id)); //Set the params

//Start a output buffer
ob_start();
$page2 = $route->dispatch(); //run the route
//Get the output
$page = ob_get_clean();

In my particular instance I need to capture the exact page and send it in an email. So by running the route and capturing the HTML i can simply send an html email with the captured page body. It works flawlessly.

Problem

How can I call a slim function from another function in different php page Here My.php: ``` $app->get('/list/:id',function($id) { //fill array here echo $somearray; }); $app->post('/update/:id',function($id) { //do update operation here //!Important : How can do this? echo $app->get('My.php/list/$id'); // call function above }); ```

Original source