Versioing in slim 3

I am very much naive in slim. Currently I am using

$app->get(’/verification’, function ($request, $response, $args) { });

pattern for routing. So my end point can be accessed by .

Now I want to access my end point like

But I don’t know how to do it. Can any one help?

Put your routes inside a group:

$app->group('/v1', function () use ($app)  {
    $app->get('/verification', function ($request, $response, $args) { });
1 Like

Here is the code

$app->group('/v1', function () (use $app)  {
	$app->get('/allmoffices', function ($request,$response,$args) {
		return $response->withJson($returnArray,201);

I am getting this error.

Parse error: syntax error, unexpected ‘(’, expecting ‘{’ in /Users/sharif/Sites/binameer/api/app/routes/allstatics.php on line 26

I think I am doing wrong some where or I couldn’t get it right. If you can give me a example link, it will be helpful.

That’s the thing with off-the-cuff replies, you need to check the syntax of any given code and ensure that it’s valid PHP.

Check the syntax for use in and you’ll see that it’s: use ($var).