Author Topic: ZF: Controllers Showing Up Blank  (Read 437 times)

0 Members and 1 Guest are viewing this topic.

Offline Swamp56Topic starter

  • Irregular
  • Posts: 3
    • View Profile
ZF: Controllers Showing Up Blank
« on: June 03, 2009, 11:40:49 AM »
I've been making a forum system with Zend Framework for a little while now (I originally used my own OOP framework, but decided this was easier ;) ).

Ok, so I extended the Zend_Controller_Action class and made my own version, as is shown here.

If you notice, I have instantiated a class called Messages, which is for the private message system that I'm creating. The issue is that when I instantiate that, everything goes blank; I can't access any controllers. The code for that class is here. Please note that it's a bit messy at the moment as I'm not even close to being done with it.

I have tried emptying the class by having no functions to no avail. I can't figure out what the hell is going on that would make all of my controllers blank. I checked the source and there's nothing as well. I have asked fellow programming friends and they were stumped too.

Any help is greatly appreciated  ;D !

Offline PFMaBiSmAd

  • Guru
  • 'Insane!'
  • *
  • Posts: 14,588
  • In Coding, Automatic means you write code to do it
    • View Profile
Re: ZF: Controllers Showing Up Blank
« Reply #1 on: June 03, 2009, 11:56:44 AM »
You likely have a fatal parse or fatal runtime error. You should be learning php, developing php code, and debugging php code on a system with error_reporting set to E_ALL and display_errors set to ON to get php to help you with errors it finds. Those two settings must be set before your code is parsed in order to help show fatal parse errors because you code is never executed in that case.

And not many people are going to visit links you put in your post. If you want someone to examine your code you will need to post it in the forum.
Signature: (not a comment about anything you posted unless specifically indicated)
Debugging step #1: To get past the garbage-out equals garbage-in stage in your code, you must check that the inputs to your code are what you expect.

Programming is just problem solving, but it is done in another language. You must learn enough of the programming language you are using to be able to read and write code.

Offline Swamp56Topic starter

  • Irregular
  • Posts: 3
    • View Profile
Re: ZF: Controllers Showing Up Blank
« Reply #2 on: June 03, 2009, 12:20:30 PM »
You likely have a fatal parse or fatal runtime error. You should be learning php, developing php code, and debugging php code on a system with error_reporting set to E_ALL and display_errors set to ON to get php to help you with errors it finds. Those two settings must be set before your code is parsed in order to help show fatal parse errors because you code is never executed in that case.

And not many people are going to visit links you put in your post. If you want someone to examine your code you will need to post it in the forum.

I've done both of those things as well as allow ZF to throw exceptions in case of any error.  Here is the code that I linked:

/application/usr/models/Controller.php
Code: [Select]
<?php

/**
 * @author C. Fitzpatrick
 * @copyright 2009
 */

class Controller extends Zend_Controller_Action
{
public function init()
{
// Instantiate various objects
$this->session->info = new Zend_Session_Namespace('info');
$this->users = new Users;
$this->messages = new Messages;

// Retrieve variables from index 
$this->smarty Zend_Registry::get('smarty');
$this->config Zend_Registry::get('config');

// Assign variables into smarty
$this->smarty->assign('site_name'$this->config->site->name);
$this->smarty->assign('site_url'$this->config->site->url);
$this->smarty->assign('users'$this->users);
$this->smarty->assign('session'$this->session);

// Register permissions if a user is set
if (isset($this->session->info->user_id))
{
$this->permissions $this->users->returnUsersGroupPermissions($this->session->info->user_id);

// Make sure the class returns the permissions as an array and not null
if (is_array($this->permissions))
{
$this->smarty->assign('permissions'$this->permissions);
}
}

}
}

?>

/application/usr/models/Messages.php
Code: [Select]
<?php

/**
 * @author C. Fitzpatrick
 * @copyright 2009
 */

/*
 * Messages class handles all of the private message
 * functions for the forum
 * 
 * @author C. Fitzpatrick
 * @version 1.0
 * @access public
 */
class Messages extends Zend_Db_Table_Abstact
{
/*
 * @var object
 * @access private
 */
private $database;

/*
 * void __construct()
 * 
 * Constructor method for the Messages class,
 * allows the database to be initialized.
 * 
 * @access public
 * @return void
 */
public function __construct()
{
$this->database Zend_Registry::get('database');
}

/*
 * int returnNumNewMessages(int $userId)
 * 
 * Returns the number of new private messages
 * that a user has.
 * 
 * @param int $userId
 * @access public
 * @return $this->database->fetchAll($query)
 */
public function returnNumNewMessages($userId)
{
$query "SELECT COUNT(*) FROM `messages` WHERE recipient='$userId' && viewed='0'";

return $this->database->fetchAll($query);
}

/*
 * bool composeMessage(int $username, int $recipient, string $message)
 * 
 * Composes a message between 2 members, and returns true if sent and
 * false if not sent
 * 
 * @param $username
 * @param $recipient
 * @param $message
 * @access public
 * @return bool
 */
public function composeMessage($username$recipient$message)
{

}

/*
 * bool deleteMessage(int $id)
 * 
 * Deletes a message from a users inbox
 * 
 * @param $id
 * @access public
 * @return bool
 */
public function deleteMessage($id)
{

}

/*
 * array returnMessageInformation($id)
 * 
 * Returns message and post information for a
 * specific message by id
 * 
 * @param $id
 * @access public
 * @return array
 */
public function returnMessageInformation($id)
{
$messagesQuery "SELECT * FROM `messages` WHERE message_id='$id'";
$postQuery "SELECT * FROM `posts` WHERE section='pm' && tid='$id'";

return array('messageInfo' => $this->database->fetchAll($messagesQuery), 'postInfo' => $this->database->fetchAll($postQuery));
}
}

?>
« Last Edit: June 03, 2009, 12:23:49 PM by Swamp56 »