FewFlyBy FewFlyBy - 3 months ago 36
PHP Question

Access multiple GET parameters in Slim Framework v3

I have a script code which will redirect to

http://localhost:8080/generated/sample/ + $('form.wpcf7-form').serialize();

and a sample generated url of that is


The serialized value is from the
Contact Form 7
plugin of WordPress.

In my slim route I have

// Routes

$app->get('/{name}', function ($request, $response, $args) {
// Sample log message
$this->logger->info("Slim-Skeleton '/' route");

// Render index view
return $this->renderer->render($response, 'index.phtml', $args);

$app->get('/generated/sample/', function ($request, $response, $args) {
return $args['your-email'];
// How to access different parameters here?

And what I get is this

enter image description here

It's like the first route is working for that but not the route that I want.

How can I access those parameters like the name, email, and all of it in my route?

Any help would be much appreciated.


You can access query string parameters with $request->getQueryParams(). Ie. something like

$params = $request->getQueryParams();
$email = $params["your-email"];

Or shorter version.

$email = $request->getQueryParam("your-email");