View Single Post
  #1 (permalink)  
Old 06-14-2008, 12:29 PM
Foom Foom is offline
Junior Member
 
Join Date: Jun 2008
Posts: 1
Unhappy Simple example of book: problem with dispatch()

Hi

I have got some code from the book Apress - Practical Web 2.0 Applications with PHP (Code from Chapter 2 is here) but it doesn't work like it should. Does anyone know why

I have an index.php which loads the Zend library and I added one controller.

In the book they added the command $controller->dispatch(); at the end of index.php - but when I run the code with this command I get an 'invalid controller specified (error)'.... \Standard.php on line 249.

In the source code they don't have this $controller->dispatch(); and the code works well.

Is it correct to leave this dispatch() out of the code?

Thank you

Directories:
Code:
/htdocs
/include
    /Controllers
    /Zend (Zend Library is here)
index.php:
PHP Code:
<?php
    
require_once('Zend/Loader.php');
    
Zend_Loader::registerAutoload();

    
// handle the user request
    
$controller Zend_Controller_Front::getInstance();
    
$controller->setControllerDirectory('../include/Controllers');
    
    
// ---- here is my problem - dispatch does not work
    // $controller->dispatch();
?>
.htaccess:
Code:
RewriteEngine on
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1
IndexController.php in /include/Controllers :
PHP Code:
<?php
    
class IndexController extends CustomControllerAction {

        public function 
indexAction() {
        }
    }
?>
CustomControllerAction.php in /include :
PHP Code:
<?php
    
class CustomControllerAction extends Zend_Controller_Action {

        function 
init() {

        }
    }
?>
Reply With Quote