I'm trying to open the localhost: 8080 / url but it always has a fatal error (Uncaught Zend \ Router \ Exception \ RuntimeException) that I can not interpret right.
My directories look 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 \ ProjectZF2 \ vendor \ zendframework \ zend-router \ src \ Http \ Segment.php: 218 Stack trace: # 0
C: \ Users \ Igor \ Desktop \ ProjectZF2 \ vendor \ zendframework \ zend-router \ src \ Http \ Segment.php (112): Zend \ Router \ Http \ Segment-> parseRouteDefinition (' : actio ... ') # 1
C: \ Users \ Igor \ Desktop \ ProjectZF2 \ vendor \ zendframework \ zend-router \ src \ Http \ Segment.php (147): Zend \ Router \ Http \ : actio ... ', Array, Array) # 2
C: \ Users \ Igor \ Desktop \ ProjectZF2 \ vendor \ zendframework \ zend-router \ src \ RouteInvokableFactory.php (105): Zend \ Router \ Http \ Segment :: factory (Array) Zend \ Router \ RouteInvokableFactory-> __ invoke (Object (Zend \ ServiceManager \ ServiceManager)), and the Zend \ 'Zend \ Router \ Htt ...', Array) # 4
Zend \ ServiceManager \ ServiceMan inC: \ Users \ Igor \ Desktop \ ProjectZF2 \ vendor \ zendframework \ zend-servicemanager \ src \ ServiceManager.php on line 771
Files (I'll only put the ones I've 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',
],
],
];
PersonController.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>