2008年11月26日星期三

[fw-mvc] RE: path windows problem (wamp)

My bootstrap (application/bootstrap.php):

The web site works fine on Linux SO/Mac server and does not work on windows (with wampserver).. On my linux server (online) works fine see: http://bragaempresas.t2.trafegonacional.com/

In someone windows paths don't work.. (css files)...

<?php
// APPLICATION CONSTANTS - Set the constants to use in this application.
defined('APPLICATION_PATH') or define('APPLICATION_PATH', dirname(__FILE__));

defined('APPLICATION_ENVIRONMENT') or define('APPLICATION_ENVIRONMENT', 'development');

// FRONT CONTROLLER - Get the front controller.
$frontController = Zend_Controller_Front::getInstance();

// CONTROLLER DIRECTORY SETUP - Point the front controller to your action $frontController->setControllerDirectory(array(
'default' => APPLICATION_PATH . '/controllers',
'BackOffice' => APPLICATION_PATH . '/BackOffice/controllers'
));

// APPLICATION ENVIRONMENT - Set the current environment $frontController->setParam('env', APPLICATION_ENVIRONMENT);

$options = array(
'layout' => 'layout',
'layoutPath' => APPLICATION_PATH . '/layouts/scripts',
'contentKey' => 'content' // ignored when MVC not used
);

// LAYOUT SETUP - Setup the layout component Zend_Layout::startMvc($options);

// VIEW SETUP - Initialize properties of the view object $view = Zend_Layout::getMvcInstance()->getView();
$view->doctype('XHTML1_STRICT');

// CONFIGURATION - Setup the configuration object $config = new Zend_Config_Ini(APPLICATION_PATH . '/config/app.ini', APPLICATION_ENVIRONMENT);

$registry = Zend_Registry::getInstance(); $registry->set('config', $config);

// DATABASE ADAPTER - Setup the database adapter // DATABASE TABLE SETUP - Setup the Database Table Adapter $db = Zend_Db::factory('PDO_MYSQL', array(
'host' => 'localhost',
'username' => 'portal',
'password' => 'portal',
'dbname' => 'portal'
));
$db->query("SET NAMES 'UTF8'");
$db->query("SET CHARACTER SET 'UTF8'");
Zend_Db_Table::setDefaultAdapter($db);
Zend_Registry::set('db', $db);

$baseUrl = substr($_SERVER['PHP_SELF'], 0, strpos($_SERVER['PHP_SELF'], '/index.php'));

// CLEANUP - remove items from global scope unset($frontController, $view, $config, $db, $registry);

My index (public/index.php):

<?php
// APPLICATION_PATH is a constant pointing to our application/ subdirectory.

//define('APPLICATION_PATH', realpath(dirname(__FILE__) . '/../application/')); //set_include_path(APPLICATION_PATH . '/../library' . PATH_SEPARATOR . get_include_path());


set_include_path('.'
. PATH_SEPARATOR . get_include_path()
. PATH_SEPARATOR . '../library'
. PATH_SEPARATOR . '../application/'
. PATH_SEPARATOR . '../application/models/'

);

// AUTOLOADER - Set up autoloading.
require_once "../library/Zend/Loader.php"; Zend_Loader::registerAutoload();

// REQUIRE APPLICATION BOOTSTRAP: Perform application-specific setup try {
require '../application/bootstrap.php'; } catch (Exception $exception) {
echo '<html><body><center>'
. 'Ocorreu uma excepção durante a inicializaçãoo da aplicação.';
if (defined('APPLICATION_ENVIRONMENT') && APPLICATION_ENVIRONMENT != 'production') {
echo '<br /><br />' . $exception->getMessage() . '<br />'
. '<div align="left">Stack Trace:'
. '<pre>' . $exception->getTraceAsString() . '</pre></div>';
}
echo '<br /><br /><br /><br /><pre> webmaster: Setima / info@setima.pt</pre></center></body></html>';
exit(1);
}


// DISPATCH: Dispatch the request using the front controller.
Zend_Controller_Front::getInstance()->dispatch();


My .htaccess (public/.htaccess):

# Let's make sure that we have setup the timezone for this application, # In some php.ini files, this value is not set. This will ensure it exists # for every reqeust of this application.
php_value date.timezone "UTC"

# Let's also make sure that we can use the php short tag, "<?". The # reason this is enabled is so that we can use these short tags in our # php based view scripts. This allows for a shorter and cleaner view # script, After all PHP IS A TEMPLATING LANGUAGE :) php_value short_open_tag "1"

# Set the error_reporting to E_ALL|E_STRICT # Since .htaccess only take an integer (and cannot render the PHP # contstants, we need to find out what the integer actuall is) # # > php -r "echo E_ALL|E_STRICT;"
# 8191
php_value error_reporting "8191"

# The following display_*error directives instruct PHP how to display # errors that might come up. In a production environment, it might # be good to set these values inside the actual VHOST definiation.
# NOTE: these display error ini's should most likely be OFF # in your production environment php_value display_startup_errors "1"
php_value display_errors "1"

# NOTE: by setting the above php ini values, we are ensuring that # regardless of the servers php.ini values, we can be assured that # our application will have these set values set on every request.

# The rules below basically say that if the file exists in the tree, just # serve it; otherwise, go to index.php. This is more future-proof for your # site, because if you start adding more and more content types, you don't # need to alter the .htaccess to accomodate them.
# This is an important concept for the Front Controller Pattern which the # ZF MVC makes use of.
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ index.php [NC,L]

Saudações Cordiais,
Miguel Vieira
Tecnlogias da informação e Comunicação
+351 93 336 27 07
CONFIDENTIALITY: This message and any files transmitted with it may contain confidential and/or privileged information and is intended solely for the use of the addressee. If you are not the intended recipient or the person authorised to deliver it to the addressee, you are advised that you have received the message in error. Any use, dissemination, forwarding, printing or copying of this is strictly prohibited. Please notify the sender by return of mail and delete the material. Thank you for your cooperation.


-----Mensagem original-----
De: Miguel Vieira Dr. (e-mail pessoal) [mailto:vieira@miguelvieira.com.pt]
Enviada: quarta-feira, 26 de Novembro de 2008 11:15
Para: fw-mvc@lists.zend.com
Assunto: path windows problem (wamp)

Hi,

I am running a zend application on my wamp server (on windows vista), and path's don't work... css files don't work when I change controllers... In linux server works fine

Is a bug? On Framework 1.5 works fine in my computer (windows+wamp), When I started to use bootstrap this problems happens... can someone help me?

Saudações Cordiais,
Miguel Vieira

没有评论: