The Slim Framework support forum has moved to This Tender forum is no longer maintained or monitored.

pass application

Joe's Avatar


26 Jan, 2016 05:03 PM

I have a question, and hopefully I ask it correctly.

The setup is I have a page api.php that is accessed via CURL.

$app->post('/products',function() use ($app){
$pl = new SomeClass();
$something = $pl->loadApi($app->pass());

The loadApi function of the class has this:
public function loadApi(&$api) {
                        // do some stuff

try {
echo json_encode($stuff);
} catch (Exception $e) {
echo '{"error":{"text":' . $e->getMessage() . '}}';

Now is there any way I can get that json inside of the original function where $something is rather than it going to the original location the call was made from?

  1. 1 Posted by Joe on 26 Jan, 2016 05:48 PM

    Joe's Avatar

    Or is it possible to set the response in one class (Module) and then retrieve it from the $app in the original class? Since I'm passing by reference.

Reply to this discussion

Internal reply

Formatting help / Preview (switch to plain text) No formatting (switch to Markdown)

Attaching KB article:


Attached Files

You can attach files up to 10MB

If you don't have an account yet, we need to confirm you're human and not a machine trying to post spam.

Keyboard shortcuts


? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac