0
I have a route on my website which is linked to a module called Cart, but although everything seems to be according to the tutorial and documentation of zend, this route is not found and always from erro 404
.
After several attempts of different modifications to see if the code worked, I then modified the name of the module for Cart2, and also the namespaces
of their respective files (Controllers, Entities, Models...). Oddly enough, the route is now found, only changing the name of the module. But it is really necessary that the module name is Cart.
I gave one Find
on the project to see if that word Cart was in some configuration file that could compromise the module with that name and found nothing.
Has anyone there been through it and/or has an idea of what it might be?
modules/Cart/config/module.config.php:
<?php
namespace Carrinho;
use Zend\Router\Http\Segment;
return array(
'router' => array(
'routes' => array(
'carrinho' => array(
'type' => Segment::class,
'options' => array(
'route' => '/carrinho[/:action][/:produto][/:dados]',
'constraints' => array(
'action' => '[a-zA-Z][a-zA-Z0-9_-]*',
'produto' => '[a-zA-Z0-9_,]*',
'dados' => '[a-zA-Z0-9_=]*',
),
'defaults' => array(
'controller' => Controller\CarrinhoController::class,
'action' => 'index',
),
),
),
),
),
'view_manager' => array(
'template_path_stack' => array(
'carrinho' => __DIR__ . '/../view',
),
),
'asset_manager' => array(
'resolver_configs' => array(
'paths' => array(
__DIR__ . '/../asset',
),
),
),
);
module/Cart/src/Module.php:
<?php
namespace Carrinho;
use Zend\ModuleManager\Feature\ConfigProviderInterface;
class Module implements ConfigProviderInterface
{
const VERSION = '3.0.3-dev';
public function getConfig()
{
return include __DIR__ . '/../config/module.config.php';
}
public function getControllerConfig()
{
return [
'factories' => [
Controller\CarrinhoController::class => function($container) {
return new Controller\CarrinhoController($container);
},
],
];
}
}
These are the codes that when the namespace
and the folder name, start working.
config/modules.config.php:
<?php
return [
'Zend\Log',
'Zend\Mvc\Console',
'Zend\Mvc\I18n',
'Zend\Mvc\Plugin\FilePrg',
'Zend\Mvc\Plugin\FlashMessenger',
'Zend\Mvc\Plugin\Identity',
'Zend\Mvc\Plugin\Prg',
'Zend\Navigation',
'Zend\Serializer',
'Zend\ServiceManager\Di',
'Zend\Paginator',
'Zend\Cache',
'Zend\Session',
'Zend\Mail',
'Zend\Form',
'Zend\InputFilter',
'Zend\Filter',
'Zend\Hydrator',
'Zend\I18n',
'Zend\Router',
'Zend\Db',
'Zend\Validator',
'AwsModule',
'AssetManager',
'Neilime\MobileDetect',
'Carrinho',
'Catalogo',
'Cliente',
'Geral',
'Localidade',
'Sitemap',
//'Carrinho2',
];
One enters the post, should never have used zend, and downvote only because he did not understand the question, without even saying what problem she saw in the question for that... This community is to be congratulated.
– David Alves
You never checked the cache? I use zend 1 and it caches the routes so it has curled when it was giving error and even after being corrected the error persists.
– fajuchem
Already checked yes @fajuchem, in the development environment is not caching the routes. =/
– David Alves
Shows the code of where you assemble the routes and where you make the links. Without the code it is difficult to help.
– fajuchem