Estou tentando abrir abrir a url localhost:8080/pessoa porém sempre apresenta um fatal error ( Uncaught Zend\Router\Exception\RuntimeException) que nao consigo interpretar direito.
Meus diretorios estao assim:
-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\ProjetoZF2\vendor\zendframework\zend-router\src\Http\Segment.php:218 Stack trace: #0
C:\Users\Igor\Desktop\ProjetoZF2\vendor\zendframework\zend-router\src\Http\Segment.php(112): Zend\Router\Http\Segment->parseRouteDefinition('/pessoa[/:actio...')#1
C:\Users\Igor\Desktop\ProjetoZF2\vendor\zendframework\zend-router\src\Http\Segment.php(147): Zend\Router\Http\Segment->__construct('/pessoa[/:actio...', Array, Array) #2C:\Users\Igor\Desktop\ProjetoZF2\vendor\zendframework\zend-router\src\RouteInvokableFactory.php(105): Zend\Router\Http\Segment::factory(Array) #3
C:\Users\Igor\Desktop\ProjetoZF2\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\ProjetoZF2\vendor\zendframework\zend-servicemanager\src\ServiceManager.php(227): Zend\ServiceManager\ServiceMan in
C:\Users\Igor\Desktop\ProjetoZF2\vendor\zendframework\zend-servicemanager\src\ServiceManager.php on line 771
Arquivos (Vou colocar apenas os que eu editei):
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',
],
],
];
PessoaController.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>
]
na linha'route' => '/pessoa[/:action[/:id]',
emmodule.config.php
– Costamilam 13/10/18 às 23:04