Reputation:
I'm trying to pass some parameters on a slim route. I got this function in a file called Usuarios.php
function IniciarSesion($app)
{
VerificarParametrosRequeridos(array('NombreUsuario', 'Contrasena'));
$json = $app->request->getBody();
$datapost = json_decode($json, TRUE);
}
And I got this route on a index.php that requires the Usuarios.php file
require 'vendor/autoload.php';
require 'DbConnect.php';
$app = new \Slim\Slim();
$app->pdo = new DbConnect();
require 'app/Usuarios.php';
$app->post('/usuarios/login','IniciarSesion');
And I want to pass to the route that call the IniciarSesion function, the $app var declare in index.php
is that possible?
Upvotes: 2
Views: 1423
Reputation: 161
Hey as you can use getInstance()
static method.
Check it here:
http://docs.slimframework.com/configuration/names-and-scopes/
<?php
use Slim\Slim;
$app = new Slim();
$app->get('/foo', 'foo');
function foo() {
$app = Slim::getInstance();
$app->render('foo.php');
}
Upvotes: 1