TalkPHP
 
 
Account Login
Latest Articles
» The basic usage of PHPTAL, a XML/XHTML template library for PHP
» Vulnerable methods and the areas they are commonly trusted in.
» Simple way to protect a form from bot
» The Basics On: How Session Stealing Works
» How to keep your forms from double posting data
IRC Channel
IRC Speech Bubble Join the friendly bunch on IRC...
(#TalkPHP on Freenode)

...Also available via a web interface.

See this thread for information on the TalkPHP Free Hugs Initiative™. Subject to availability.
Associates
Associates
CSS Tutorials
Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old 05-07-2009, 03:13 AM   #1 (permalink)
Orc
The Prestige
 
Orc's Avatar
 
Join Date: Dec 2007
Posts: 1,044
Thanks: 193
Orc is on a distinguished road
Default Cannot access an Action via url

When you try to access an action in the url in Zend Framework: "http://www.example.com/index/action/" it doesn't seem to access the method in the Action Controller, what am I doing wrong?
__________________
VillageIdiot can have my babbies ;d
Orc is offline  
Reply With Quote
Old 05-07-2009, 03:59 AM   #2 (permalink)
Wizard
Top Contributor 
 
Village Idiot's Avatar
 
Join Date: Sep 2007
Posts: 1,299
Thanks: 17
Village Idiot is on a distinguished road
Default

Can you post the code?
__________________

Village Idiot is offline  
Reply With Quote
Old 05-07-2009, 04:03 AM   #3 (permalink)
Orc
The Prestige
 
Orc's Avatar
 
Join Date: Dec 2007
Posts: 1,044
Thanks: 193
Orc is on a distinguished road
Default

Quote:
Originally Posted by Village Idiot View Post
Can you post the code?
Index.php
Code:
<?php
define("THIS_PAGE", "index");
define('BASE_PATH', realpath(dirname(__FILE__) . '../'));
define('APPLICATION_PATH', BASE_PATH . '/application');

set_include_path(BASE_PATH . '/library/incubator'
    . PATH_SEPARATOR .BASE_PATH . '/library'
    . PATH_SEPARATOR . get_include_path()
);

// APPLICATION_ENVIROMENT defines which config section is loaded
if(!defined('APPLICATION_ENVIRONMENT')) {
    define('APPLICATION_ENVIRONMENT', 'production');
}

require_once 'Zend/Application.php';

$application = new Zend_Application(APPLICATION_ENVIRONMENT,
    array(
        'bootstrap'=>array('path'=>APPLICATION_PATH.'/Bootstrap.php'),
        'autoloadernamespaces' => array('Zend', 'App')
    ));
$application->bootstrap();
$application->run();        
?>
application/controllers/IndexController.php
Code:
<?php

class IndexController extends Zend_Controller_Action
{

    public function init()
    {

		echo "This will output though.";
    	
    }

    public function indexAction()
    {
       
    	echo "This won't output.";
    	
    }


}
application/Bootstrap.php
Code:
<?php

class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
{

	protected $_config;

	public function _initConfig()
	{
		// config
		$this->_config = new Zend_Config_Ini(APPLICATION_PATH
		. '/configs/application.ini', APPLICATION_ENVIRONMENT);
		Zend_Registry::set('config', $this->_config);
		Zend_Registry::set('env', APPLICATION_ENVIRONMENT);

		// debugging
		if($this->_config->debug) {
			error_reporting(E_ALL | E_STRICT);
			ini_set('display_errors', 'on');
		}
	}

	protected function _initAutoload()
	{
		$moduleLoader = new Zend_Application_Module_Autoloader(array(
		'namespace' => '',
		'basePath' => APPLICATION_PATH));
		return $moduleLoader;
	}

	public function _initDB()
	{
		// Database
		if($this->_config->db) {
			$dbAdapter = Zend_Db::factory($this->_config->db);
			Zend_Db_Table_Abstract::setDefaultAdapter($dbAdapter);
			Zend_Registry::set('dbAdapter', $dbAdapter);
		}
	}

	public function _initView()
	{
		// view and layout setup
		Zend_Layout::startMvc(APPLICATION_PATH . '/views/layouts');
		$view = Zend_Layout::getMvcInstance()->getView();
	}

	public function _initFrontController()
	{
		$frontController = Zend_Controller_Front::getInstance();
		$frontController->setControllerDirectory(APPLICATION_PATH .'/controllers');
		$frontController->setParam('env', APPLICATION_ENVIRONMENT);

		// action helpers
		Zend_Controller_Action_HelperBroker::addPath(APPLICATION_PATH .'/controllers/helpers');
	}

	public function run()
	{
		$frontController = Zend_Controller_Front::getInstance();
		$frontController->dispatch();
	}


}

?>
__________________
VillageIdiot can have my babbies ;d
Orc is offline  
Reply With Quote
Old 05-07-2009, 11:34 AM   #4 (permalink)
La Vida es Sueño
Advanced Programmer Top Contributor 
 
Wildhoney's Avatar
 
Join Date: Sep 2007
Location: Oldham
Posts: 2,280
Thanks: 90
Wildhoney is on a distinguished road
Default

You're asking a lot here! A lot of code to look through. Try accessing this URL though: http://www.example.com/index/index/

It looks like you're calling the action "action", which would be public function actionAction().

__________________
The man who comes back through the Door in the Wall will never be quite the same as the man who went out.

Last edited by Wildhoney : 05-07-2009 at 03:40 PM.
Send a message via AIM to Wildhoney Send a message via MSN to Wildhoney Send a message via Yahoo to Wildhoney
Wildhoney is offline  
Reply With Quote
Old 05-07-2009, 03:22 PM   #5 (permalink)
The Gregarious
 
allworknoplay's Avatar
 
Join Date: Feb 2009
Location: New York
Posts: 645
Thanks: 64
allworknoplay is on a distinguished road
Default

Quote:
Originally Posted by Wildhoney View Post
You're asking a lot here! A lot of code to look through. Try accessing this URL though: http://www.example.com/index/index/

It looks like you're calling the action "action", which would be public function actionAction().

WH,

What program are you using to create these quick diagrams?
allworknoplay is offline  
Reply With Quote
Old 05-07-2009, 03:38 PM   #6 (permalink)
La Vida es Sueño
Advanced Programmer Top Contributor 
 
Wildhoney's Avatar
 
Join Date: Sep 2007
Location: Oldham
Posts: 2,280
Thanks: 90
Wildhoney is on a distinguished road
Default

The Lovely YUML.me!
__________________
The man who comes back through the Door in the Wall will never be quite the same as the man who went out.
Send a message via AIM to Wildhoney Send a message via MSN to Wildhoney Send a message via Yahoo to Wildhoney
Wildhoney is offline  
Reply With Quote
Old 05-07-2009, 03:44 PM   #7 (permalink)
The Gregarious
 
allworknoplay's Avatar
 
Join Date: Feb 2009
Location: New York
Posts: 645
Thanks: 64
allworknoplay is on a distinguished road
Default

Quote:
Originally Posted by Wildhoney View Post
The Lovely YUML.me!
Nice!!! I love it!!
allworknoplay is offline  
Reply With Quote
Old 05-07-2009, 10:01 PM   #8 (permalink)
Orc
The Prestige
 
Orc's Avatar
 
Join Date: Dec 2007
Posts: 1,044
Thanks: 193
Orc is on a distinguished road
Default

Quote:
Originally Posted by Wildhoney View Post
You're asking a lot here! A lot of code to look through. Try accessing this URL though: http://www.example.com/index/index/

It looks like you're calling the action "action", which would be public function actionAction().

I understand how it works, but the problem is when trying to actually access that action via the url.

Say I had a guestbook which linked to example.com/guestbook/

Thing is it wouldn't access the indexAction of the GuestbookController, nor would it access any other actions if I also applied those in the url.
__________________
VillageIdiot can have my babbies ;d
Orc is offline  
Reply With Quote
Old 05-08-2009, 06:13 PM   #9 (permalink)
Orc
The Prestige
 
Orc's Avatar
 
Join Date: Dec 2007
Posts: 1,044
Thanks: 193
Orc is on a distinguished road
Default

Fixed it so far, had something to do with $this->layout()->content not in the layout script. :P
__________________
VillageIdiot can have my babbies ;d
Orc is offline  
Reply With Quote
Old 05-11-2009, 04:12 AM   #10 (permalink)
The Wanderer
 
foobarph's Avatar
 
Join Date: May 2009
Posts: 23
Thanks: 4
foobarph is on a distinguished road
Default

so the layout thingy is the culprit. nice job orc.

*pokes wildhoney* haha! :)
foobarph is offline  
Reply With Quote
Old 05-11-2009, 03:01 PM   #11 (permalink)
Orc
The Prestige
 
Orc's Avatar
 
Join Date: Dec 2007
Posts: 1,044
Thanks: 193
Orc is on a distinguished road
Default

Quote:
Originally Posted by foobarph View Post
so the layout thingy is the culprit. nice job orc.

*pokes wildhoney* haha! :)
Still learning.
__________________
VillageIdiot can have my babbies ;d
Orc is offline  
Reply With Quote
The Following User Says Thank You to Orc For This Useful Post:
foobarph (05-13-2009)
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
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

Similar Threads
Thread Thread Starter Forum Replies Last Post
How do I design my access control system ? amitdgr General 4 04-21-2009 09:21 AM
MS Access via FTP Jenski Advanced PHP Programming 3 02-04-2009 03:27 PM
access css thorugh javascript freenity Javascript, AJAX, E4X 3 02-29-2008 04:35 PM
Building an Apache-like Access Control List (ACL) Wildhoney General 2 12-14-2007 02:03 PM
How to access functions of Cpanel? jaswinder_rana Absolute Beginners 3 07-15-2005 05:53 PM


All times are GMT. The time now is 05:29 PM.

 
     

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Inactive Reminders By Icora Web Design