0
I am using apigility (ZF2). The following error occurs when submitting a request: The requested URL could not be Matched by routing. The error occurs when I try to make a request get through the link: http://0.0.0.0:8888/leads
using Postman (Chrome plugin).
Supposedly the error refers to some route error. However, you cannot notice this error yet.
The directory structure follows below:
The code of my chat/module.php file is as follows:
<?php
namespace chat;
use chat\V1\Rest\Leads\LeadsEntity;
use chat\V1\Rest\Leads\LeadsMapper;
use Zend\Db\ResultSet\ResultSet;
use Zend\Db\TableGateway\TableGateway;
use ZF\Apigility\Provider\ApigilityProviderInterface;
class Module implements ApigilityProviderInterface
{
public function getConfig()
{
return array(
'factories' => array(
'chatLeadsTableGateway' => function($sm) {
$dbAdapter = $sm->get('Adaptador');
$resultSetPrototype = new ResultSet();
$resultSetPrototype->setArrayObjectPrototype(new LeadsEntity());
return new TableGateway('nomedatable', $dbAdapter, null, $resultSetPrototype);
},
'chat\V1\Rest\Leads\LeadsMapper' => function($sm) {
$tableGateway = $sm->get('chatLeadsTableGateway');
return new LeadsMapper($tableGateway);
}
),
);
}
public function getAutoloaderConfig()
{
return array(
'ZF\Apigility\Autoloader' => array(
'namespaces' => array(
__NAMESPACE__ => __DIR__,
),
),
);
}
}
The code of the chat/module.config.php file is as follows::
<?php
return array(
'router' => array(
'routes' => array(
'chat.rest.leads' => array(
'type' => 'Segment',
'options' => array(
'route' => '/leads[/:leads_id]',
'defaults' => array(
'controller' => 'chat\\V1\\Rest\\Leads\\Controller',
),
),
),
),
),
Below project folder structure
Don’t forget to hit the Return in getConfig()
– Danilo Fernando