0
I’m trying to open the localhost:8080/person url but always has a fatal error ( Uncaught Zend Router Exception Runtimeexception) that I can’t interpret right.
My directories are like this:
-config
*pplication.config.php
*development.config.php
*development,config.php.dist
*modules.config.php
-data
-module
-Application
-Pessoa
-config
*module.config.php
-src
-Controller
*PessoaController.php
*Module.php
-test
-view
-pessoa
-pessoa
*index.phtml
-public
-vendor
Stack trace:
Fatal error: Uncaught Zend Router Exception Runtimeexception: Found unbalanced Brackets in C: Users Igor Desktop Projectozf2 vendor zendframework zend-router src Http Segment.php:218 Stack trace: #0
C: Users Igor Desktop Projectozf2 vendor zendframework zend-router src Http Segment.php(112): Zend Router Http Segment->parseRouteDefinition('/person[/:actio...')#1
C: Users Igor Desktop Projectozf2 vendor zendframework zend-router src Http Segment.php(147): Zend Router Http Segment->__Construct('/person[/:actio...', Array, Array) #2C: Users Igor Desktop Projectozf2 vendor zendframework zend-router src Routeinvokablefactory.php(105): Zend Router Http Segment::Factory(Array) #3
C: Users Igor Desktop Projectozf2 vendor zendframework zend-servicemanager src Servicemanager.php(764): Zend Router Routeinvokablefactory->__invoke(Object(Zend Servicemanager Servicemanager), 'Zend Router Htt...', Array) #4
C: Users Igor Desktop Projectozf2 vendor zendframework zend-servicemanager src Servicemanager.php(227): Zend Servicemanager Serviceman in
C: Users Igor Desktop Projectozf2 vendor zendframework zend-servicemanager src Servicemanager.php on line 771
Files (I’ll put only the ones I edited):
modules.config.php
<?php
return [
'Zend\Router',
'Zend\Validator',
'Application',
'Pessoa',
];
module.config.php
<?php
namespace Pessoa;
use Zend\ServiceManager\Factory\InvokableFactory;
return [
'router' => [
'routes' => [
'pessoa' => [
'type' =>\Zend\Router\Http\Segment::class,
'options' => [
'route' => '/pessoa[/:action[/:id]',
'constraints' => [
'action' => '[a-ZA-Z][a-ZA-Z0-9_-]*',
'id' => '[0-9]+',
],
'defaults' => [
'controller' => Controller\PessoaController::class,
'action' => 'index',
],
],
],
],
],
'controllers' => [
'factories' => [
Controller\PessoaController::class => InvokableFactory::class,
],
],
'view_manager' => [
'template_path_stack' => [
'pessoa' => __DIR__. '/../view',
],
],
];
Personal controller.php
<?php
namespace Pessoa\Controller;
use Zend\Mvc\Controller\AbstractActionController;
use Zend\View\Model\ViewModel;
class PessoaController extends AbstractActionController
{
public function indexAction()
{
return new ViewModel();
}
}
Module.php
<?php
namespace Pessoa;
use Zend\ModuleManager\Feature\ConfigProviderInterface;
class Module implements ConfigProviderInterface
{
public function getConfig()
{
return include __DIR__."/../config/module.config.php";
}
}
index.phtml
<?php
$var = "Funciona!!!!!";
?>
<h1>Minha view do controller pessoa no modulo Pessoa</h1>
<p><?= $var ?></p>
I don’t know the framework, but I seem to be missing one
]
on the line'route' => '/pessoa[/:action[/:id]',
inmodule.config.php
– Costamilam
Obg for help. I put the missing clasp. But still giving error, so another -> Compilation failed: range out of order in Character class at offset 26 in C: Users Igor Desktop Projectozf2 vendor zendframework zend-router src Http Segment.php on line 387
– Igor PTZ