*This code  is for add new controller in same module *
module.config.php Code :)

  return array(
    'controllers' => array(
        'invokables' => array(
            'Bid\Controller\Bid' => 'Bid\Controller\BidController',
            'Bid\Controller\Gid' => 'Bid\Controller\GidController'

        ),
    ),

    'router' => array(
        'routes' => array(
            'bid' => array(
                'type'    => 'segment',
                'options' => array(
                    'route'    => '/bid[/:action][/:id]',
                    'constraints' => array(
                        'action' => '[a-zA-Z][a-zA-Z0-9_-]*',
                        'id'     => '[0-9]+',
                    ),
                    'defaults' => array(
                        'controller' => 'Bid\Controller\Bid',
                        'action'     => 'index',
                    ),
                ),
            ),

            'gid' => array(
                'type' => 'segment',
                'options' => array(
                    //'route' => '/gid',
                    'route'    => '/gid[/:action][/:id]',
                    'constraints' => array(
                        'action' => '[a-zA-Z][a-zA-Z0-9_-]*',
                        'id'     => '[0-9]+',
                    ),
                    'defaults' => array(
                   // '__NAMESPACE__' => 'Bid\Controller\Gid',
                    'controller'    => 'Bid\Controller\Gid',
                    'action'        => 'index',
                    ),
                ),
            ),
        ),
    ),

    'view_manager' => array(
        'template_path_stack' => array(
            'bid' => __DIR__ . '/../view',
        ),
    ),
);


GidController.php :)

<?php
namespace Bid\Controller;

use Zend\Mvc\Controller\AbstractActionController;
use Zend\View\Model\ViewModel;
use Admin\Model\User;
use Property\Controller\Plugin\propertyobj;
use Zend\Validator\File\Size;
use Zend\Session\Container;
use Property\Model\Opportunity;
use Zend\Paginator\Paginator;
use Zend\Paginator\Adapter\AdapterArray;
use Zend\Mail;
use Zend\Mail\Message;
use Zend\Mime\Message as MimeMessage;
use Zend\Mime\Part as MimePart;
use Bid\Model\Bid;
use Bid\Model\BidsTable;
use Bid\Form\BidbuyForm;
use Bid\Model\BidBuyTable;
use Property\Model\PropertyTable;

class GidController extends AbstractActionController
{
    protected $bidsTable;
    protected $bidbuyTable;
    protected $propertyTable;

   public function indexAction()
    {
        echo "hererre";die;
        $request = $this->getRequest();

    }
    public function deleteAction()
    {
        echo "hererxzxxxxxxxxxxxxxxxxxre";die;
        $request = $this->getRequest();

    }
}
On 3/16/2013 11:44 AM, Sandeep Singh wrote:
Hi All,


I want to create routes in such a way in application module that my route
is like

"controller\action"

currently it is  "application\controller\action"

currently i have 3 controller in my application module.


I am also looking to create more modules. So please suggest how can i make
routes like controller/action




My config is given below:

'routes' => array(
             'home' => array(
                 'type' => 'Zend\Mvc\Router\Http\Literal',
                 'options' => array(
                     'route'    => '/',
                     'defaults' => array(
                         'controller' => 'Application\Controller\Index',
                         'action'     => 'index',
                     ),
                 ),
             ),
             // The following is a route to simplify getting started creating
             // new controllers and actions without needing to create a new
             // module. Simply drop new controllers in, and you can access
them
             // using the path /application/:controller/:action
             'application' => array(
                 'type'    => 'Literal',
                 'options' => array(
                     'route'    => '/application',
                     'defaults' => array(
                         '__NAMESPACE__' => 'Application\Controller',
                         'controller'    => 'Index',
                         'action'        => 'index',
                     ),
                 ),
                 'may_terminate' => true,
                 'child_routes' => array(
                     'default' => array(
                         'type'    => 'Segment',
                         'options' => array(
                             'route'    => '/[:controller[/:action]]',
                             'constraints' => array(
                                 'controller' => '[a-zA-Z][a-zA-Z0-9_-]*',
                                 'action'     => '[a-zA-Z][a-zA-Z0-9_-]*',
                             ),
                             'defaults' => array(
                             ),
                         ),
                     ),
                 ),
             ),


Reply via email to