return [
'router' => [
'routers' => [
'api-login' => [ // REST
'type' => 'Literal',
'options' => [
'route' => '/api/login',
'defaults' => [
'controller' => 'YourModule\Controller\Login'
],
],
],
'login' => [
'type' => 'Literal',
'options' => [
'route' => '/login',
'defaults' => [
'controller' => 'YourModule\Controller\Login'
'action' => 'login',
],
],
],
],
],
'view_manager' => [
'strategies' => [
'ViewJsonStrategy',
],
],
'controllers' => [
'invokables' => [
'YourModule\Controller\Login' => 'YourModule\Controller\LoginController',
],
],
];
class LoginController extends AbstractRestfulController {
public function create($data) {
// POST the data came at REST
return new JsonModel(['status' => 'error', 'message' => 'Username and/or password is not correct.']);
}
public function getList() {
// GET the data without the id
return new JsonModel(['item1', 'item2', 'item3']);
}
public function loginAction() {
// normal Action
return new ViewModel();
}
}
Find more questions by tags RESTful APIZend Framework