Welcome, Guest. Register Now!
   
Mark Forums Read Mark Forums Read Mark Forums Read


Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 03-10-2008, 03:51 AM
Junior Member
 
Join Date: Mar 2008
Posts: 2
Default Subclass And Action Controllers

I am having issues.

I am readying through: Practical Web 2.0 Applications with PHP.

I am stuck on a part in chapter 2 involving the "CustomControllerAction.php" file (for those of you how own the book or you can check it out here Apress Practical Web 2 0 Applications with PHP Dec 2007)

Anyway it isn't working. Even the example code doesn't seem to work.

I've been looking up the zend framework docs and believe he is using a subclass or action controller. Anyway my main class extends the CustomControllerAction class (which in turn extends the Zend_Controller_Action), but when I load the page the script can't find the CustomControllerAction class.

Included are the is the code for my bootstrap file, registration class file and customcontrolleraction file:

bootstrap:
Code:
<?php

	//Error Reporting
	error_reporting(E_ALL|E_STRICT);
	ini_set('display_errors', 'on');
	
	//modify include path to include path to library
	ini_set('include_path', ini_get('include_path') . PATH_SEPARATOR . '../library');
	
	//Zend Framework include
	require_once 'Zend/Loader.php';
	Zend_Loader::registerAutoload();
	
	//Initialize config
	$config = new Zend_Config_Ini('../application/config.ini', 'development');
	
	//Get the front controller instance
	$front = Zend_Controller_Front::getInstance();
	$front->setControllerDirectory('../application/controllers');
	
	$db = Zend_Db::factory($config->database->type, array(
	    'host'     => $config->database->hostname,
	    'username' => $config->database->username,
	    'password' => $config->database->password,
	    'dbname'   => $config->database->merit_optemail
	));
	
	if ($config->developer) {
		$front->throwExceptions(true);
	} else {
		$front->throwExceptions(false);
	}
	
	$front->dispatch();

?>
registration:

Code:
<?php

	/**
	* 
	*/
	class RegisterController extends CustomControllerAction
	{
		
		public function indexAction()
		{
			$this->view->name = strip_tags($_POST['customer_name']);
		}
	}
	

?>
custom controller action:

Code:
<?php

	/**
	* 
	*/
	class CustomControllerAction extends Zend_Controller_Action
	{
		public $db;
		
		public function init()
		{
			$this->db = Zend_Registry::get('db'); 
		}
	}
	

?>

dir structure:

home/
home/public_html <-- this is where the bootstrap index.php file is
home/application <-- this is where the CustomerControllerAction.php file is
home/application/controllers <-- controllers
home/library/zend <-- zend files

Let me know if more info is needed.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 03-10-2008, 03:30 PM
xentek's Avatar
Senior Member
 
Join Date: Feb 2008
Posts: 112
Default

Move your CustomerControllerAction.php to /home/application/controllers
Rename CustomerControllerAction.php to CustomerController.php
Rename Class CustomerControllerAction to CustomController

This should get you where you want to go.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT. The time now is 07:53 AM.