0 Replies - 3068 Views - Last Post: 06 February 2009 - 09:18 AM Rate Topic: -----

#1 deepbluegene   User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 8
  • Joined: 13-March 07

[SOLVED] set application path in zendframework

Posted 06 February 2009 - 09:18 AM

Hi

I was developing a application using Zend Framework.
directory structure is as follows

root/application/bootstrap.php
root/application/controllers/IndexController.php
root/application/models
root/application/modules
root/application/views
root/application/views/scripts/index/index.phtml
root/application/views/layouts/common.phtml
root/application/controllers
root/config
root/library/zend/
root/public/index.php
root/public/.htaccess

bootstrap.php
	
	require_once '../path.php';   // added path.php here
	require_once 'Zend/Loader.php';
	
	/*
	 * class BootStrap
	 */
	
	class BootStrap 
	{
		public static $frontController = null;
		
		/*
		 *	  function run
		 *	  @param 
		 */
		
		public static function run()
		{
			self::setupEnvironment();
			self::prepare();
			$response = self::$frontController->dispatch();
			self::sendResponse($response);
		} // End run
		
		
		public static function setupEnvironment()
		{
			error_reporting(E_ALL|E_STRICT);
			ini_set("display_errors", true);
			date_default_timezone_set('Australia/Sydney');
			
		}
		
		public static function prepare()
		{
			self::setupFrontController();
			self::setupView();
			
		}
		
		public static function setupFrontController()
		{
			Zend_Loader::registerAutoload();
			self::$frontController = Zend_Controller_Front::getInstance();
			self::$frontController->throwExceptions(true);
			self::$frontController->returnResponse(true);
			self::$frontController->setControllerDirectory(dirname(__FILE__).'/controllers');
		}
		
		/*
		 *	  function setupView
		 *	  @param 
		 */
		
		public static function setupView()
		{
			$view = new Zend_View();
			$view->setEncoding('UTF-8');
			$veiwRendrer = new Zend_Controller_Action_Helper_ViewRenderer($view);
			Zend_Controller_Action_HelperBroker::addHelper($veiwRendrer);
		} // End setupView
		public static function sendResponse(Zend_Controller_Response_Http $response)
		{
			/*$response->setHeader('Content-type', 'text/html: charset=UTF-8', true);*/
			$response->sendResponse();
		}
	} // End BootStrap




index.php
   $root = realpath(dirname(__FILE__));
	set_include_path(
	$root . '/application' . PATH_SEPARATOR
	. $root . '/library' . PATH_SEPARATOR);
	require_once '../application/Bootstrap.php';
	
	BootStrap::run();



.htaccess
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule .* index.php



With this code everything is working fine on my system but not on host.

I think problem is with path.

If i use dirname(__FILE__) and concatenate as above in index.php it gives path as root/public/application
and root/public/library where as both of these folders are one directory up.
i need that path be as root/application instead of root/public/application.How i can set path to these

Thanks

edit: problem solved.
may be somebody else also face same problem so i am posting solution as well.

i created a new file path.php in root directory.
path.php
		$path = dirname(dirname(__FILE__));
set_include_path(get_include_path() . PATH_SEPARATOR . $path.'/library'.PATH_SEPARATOR
				 .$path.'/application'.PATH_SEPARATOR
				 .$path.'/controllers');

	
	
	
	



then i edited bootstrap.php and included path.php as '../path.php'

and now it is working. you can check it. at Zend Blog

controller and view completed, now i will start model part of it.


thanks

This post has been edited by deepbluegene: 06 February 2009 - 09:50 AM


Is This A Good Question/Topic? 0
  • +

Page 1 of 1