1
votes
Zend2 
  Sources Files
     Application
        modules 
            default
               controllers 
                   ExampleController.php
               views
                   scripts 
                      form 
                         index.phtml

        library
          square
             form
                Form_Example.php

Hi All I am studying Zend Framework: A Beginner's guide chapter 3, i have a form_example class existing in Square/Form/Form_Example.php, it basically has a form in there.

The modules/default/controllers/ExampleControllers.php initialize it. However, i set up

resources.router.routes.example.route = /example
resources.router.routes.example.defaults.module = default           
resources.router.routes.example.defaults.controller = form
resources.router.routes.example.defaults.action = form 

in the application.ini

when i enter (http://localhost/zend2/public/example), it returns a Page Not Found result back, please help me with this in order to show the Form i create in Form_Example

Thanks, i am really appreciated

1
Have you told ZF about the routes file in your Bootstrap? - Jake N
Did you enable errors and warnings to see the actual errror? - Muhammad Zeeshan

1 Answers

0
votes

I use a separate file for routes, with this format and call it routes.ini

routes.example.route = /example
routes.example.defaults.module = default           
routes.example.defaults.controller = form
routes.example.defaults.action = form 

In your Bootstrap you then require something like this:

$front = Zend_Controller_Front::getInstance();
$router = $front->getRouter();     
$config = new Zend_Config_Ini(APPLICATION_PATH . '/configs/routes.ini', 'production');      
$router->addConfig($config,'routes');

I find that having a different file for routes makes my main .ini file less complex and it is all easier to understand.