hi have a problemn with zend framework 2 i want a create routing database for example
/hello/index => is Application/Controllers/HomeController
/CustomURL => is Application/Controllers/HomeController
the CustomUrl i retrieve from database i here is my configuration file
/// module.config.php
'router' => array(
'routes' => array(
.....
'node' => array(
'type' => 'Application\Router\Page',//src/Application/Router/Page.php
'options' => array(
'route' => '/node',
'defaults' => array(
'controller' => 'Application\Controller\Index',
'action' => 'index',
),
),
),
),
),....
here is my Router class
namespace Application\Router;
use Zend\Mvc\Router\Exception;
use Zend\Stdlib\ArrayUtils;
use Zend\Stdlib\RequestInterface as Request;
use Zend\Mvc\Router\Http;
use Zend\Mvc\Router\Http\Literal;
class Page extends Literal
{
protected $routePluginManager = null;
protected $defaults = array();
public function match(Request $request, $pathOffset = null)
{
$uri = $request->getUri();
$path = $uri->getPath();
//sample logic here
//for /about/gallery uri set node id to 1
//todo: get action, controller and module from navigation
if($path == '/node'){
$uri->setPath('/node/1');
$request->setUri($uri);
}
return parent::match($request, $pathOffset);
}
protected function buildPath(array $parts, array $mergedParams, $isOptional, $hasChild)
{
if(isset($mergedParams['link']))
{
return $mergedParams['link'];
}
return parent::buildPath($parts, $mergedParams, $isOptional, $hasChild);
}
}
im very noob and i need some help for done this part thanks
* update * i want some like post Tutorials For Database-Driven Routing in Zend Framework?
My router looks like this:
}
I call it this way:
In viewAction() in the controller, you can put whatever you want. I hope this helps.
(I have borrowed this solution frome somebody, but I cannot recall the source anymore. :( )