Skip to content
Advertisement

ZF2 Apigility Rest – unable to get multiple params

I’m using Apigility to build my Rest APIs.

I want to build have the ability to take in multiple parameters. Such as

http://mydomain.com/users/1/activities/4

I now this is possible from this page: https://github.com/zfcampus/zf-apigility/issues/10

I have edit my module route to:

'route' => '/users/:users_id/activities[/:activities_id]',

But, I don’t know how to retrieve users_id from the url.

I tried grabbing the params in my Resource php

JavaScript

But, that only returns

JavaScript

I’m a little baffled. Please advice.

Thanks!

Advertisement

Answer

In Zend Framework 2, you can use the RouteMatch to get the parameters of a route. For your case, you could try this :

JavaScript

The user_id is now in the $usr_id variable.

User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement