I have a site that I am building using Slim Framework. I have a login and registration system that uses POST variables and those routes are working fine. However, on my admin the $_GET variables just do not want to seem to register. Can anyone help me figure out what I am doing wrong? I’m using Controllers for my routes set up as:
src/Controller/Controller.php
<?php
namespace App\Controller;
use Awurth\Slim\Validation\Validator;
use Cartalyst\Sentinel\Sentinel;
use Psr\Http\Message\ServerRequestInterface as Request;
use Psr\Http\Message\ResponseInterface as Response;
use Interop\Container\ContainerInterface;
use Slim\Exception\NotFoundException;
use Slim\Flash\Messages;
use Slim\Router;
use Slim\Views\Twig;
class Controller
{
protected $container;
public function __construct(ContainerInterface $container)
{
$this->container = $container;
}
public function redirect(Response $response, $route, array $params = array())
{
return $response->withRedirect($this->router->pathFor($route, $params));
}
public function redirectTo(Response $response, $url)
{
return $response->withRedirect($url);
}
public function json(Response $response, $data, $status = 200)
{
return $response->withJson($data, $status);
}
public function write(Response $response, $data, $status = 200)
{
return $response->withStatus($status)->getBody()->write($data);
}
public function flash($name, $message)
{
$this->flash->addMessage($name, $message);
}
public function notFoundException(Request $request, Response $response)
{
return new NotFoundException($request, $response);
}
public function __get($property)
{
return $this->container->get($property);
}
}
src/Controller/AdminController.php
<?php
namespace App\Controller;
use Psr\Http\Message\ServerRequestInterface as Request;
use Psr\Http\Message\ResponseInterface as Response;
class AdminController extends Controller{
public function dashboard(Request $request, Response $response){
return $this->view->render($response, 'Admin/dashboard.twig');
}
public function users(Request $request, Response $response){
$users = new \App\Model\Users;
return $this->view->render($response, 'Admin/users.twig', ["users" => $users->get()]);
}
public function usersEdit(Request $request, Response $response, $args){
print_r($request->getQueryParams());
}
}
routes/admin.php
<?php
$app->group('/dashboard', function () {
// Dashboard Home
$this->get('', 'AdminController:dashboard')
->setName('dashboard');
// Admin Users
$this->get('/users', 'AdminController:users')
->setName('admin-users');
$this->get('/users/edit/{username}', 'AdminController:usersEdit')
->setName('admin-users-edit');
});