Hi, I am new to openEMR and i am trying to develop a zend module. For which I have followed the documentation and created zend module Test with the following folder structure;
- modules
- zend_modules
- module
- Test
- config
- module.config.php
- src
- Controller
- TestController.php
- Controller
- view
- test
- test
- index.phtml
- test
- test
- utoload_classmap.php
- Module.php
- config
- Test
- module
- zend_modules
The files are as follows:
Module.php
<?php
namespace Test;
use Laminas\ModuleManager\Feature\ConfigProviderInterface;
use Laminas\ModuleManager\ModuleManager;
class Module implements ConfigProviderInterface
{
public function getAutoloaderConfig()
{
return array(
'Laminas\Loader\ClassMapAutoloader' => array(
__DIR__ . '/autoload_classmap.php',
),
'Laminas\Loader\StandardAutoloader' => array(
'namespaces' => array(
__NAMESPACE__ => __DIR__ . '/src/' . __NAMESPACE__,
),
),
);
}
public function getConfig()
{
return include __DIR__ . '/config/module.config.php';
}
}
module.config.php
<?php
namespace Test;
use Interop\Container\ContainerInterface;
use Laminas\Router\Http\Segment;
use Laminas\Router\Http\Literal;
use Laminas\ServiceManager\Factory\InvokableFactory;
use Test\Controller\TestController;
return [
'controllers' => [
'factories' => [
TestController::class => InvokableFactory::class,
],
],
'router' => [
'routes' => [
'test' => [
'type' => Literal::class,
'options' => [
'route' => '/test',
'defaults' => [
'controller' => TestController::class,
'action' => 'index',
],
],
],
],
],
'view_manager' => [
'template_path_stack' => [
'test' => __DIR__ . '/../view',
],
],
];
TestController.php
<?php
namespace Test\Controller;
use Laminas\Mvc\Controller\AbstractActionController;
use Laminas\View\Model\ViewModel;
class TestController extends AbstractActionController
{
public function indexAction()
{
return new ViewModel([
'message' => 'Welcome to Test module!'
]);
}
}
index.phtml
<h2>Welcome to Test module</h2>
<p>This is a sample Zend module in OpenEMR.</p>
autoload_classmap.php
<?php
return array();
When I try to access url; http://localhost:8300/test , it throws error “The requested URL was not found on this server.”
Please correct me if anything I am missing or doing in a wrong way.